博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
RandomAccess接口
阅读量:4694 次
发布时间:2019-06-09

本文共 2018 字,大约阅读时间需要 6 分钟。

/** * Marker interface used by List implementations to indicate that * they support fast (generally constant time) random access.  The primary * purpose of this interface is to allow generic algorithms to alter their * behavior to provide good performance when applied to either random or * sequential access lists. * List实现所使用的标记接口,用来表明实现了这些接口的list支持快速(通常是常数时间)随机访问。  * 这个接口的主要目的是允许一般的算法更改它们的行为,以便在随机或者顺序存取列表时能提供更好的性能。
* 

The best algorithms for manipulating random access lists (such as * ArrayList) can produce quadratic behavior when applied to * sequential access lists (such as LinkedList). Generic list * algorithms are encouraged to check whether the given list is an * instanceof this interface before applying an algorithm that would * provide poor performance if it were applied to a sequential access list, * and to alter their behavior if necessary to guarantee acceptable * performance. * 操作随机访问列表(如ArrayList)的最佳算法在应用于顺序存取列表时,有可能产生二次项行为。 * 泛型算法列表鼓励在将某个算法应用于顺序存取列表可能导致差的性能之前,先检查给定的列表是否是这个接口的一个实例, * 并在需要时去改变这些算法的行为以保证性能。

* 

It is recognized that the distinction between random and sequential * access is often fuzzy. For example, some List implementations * provide asymptotically linear access times if they get huge, but constant * access times in practice. Such a List implementation * should generally implement this interface. As a rule of thumb, a * List implementation should implement this interface if, * for typical instances of the class, this loop: * 随机访问和顺序存取之间的界限通常是模糊的。例如,一些List实现在变得很大时会导致渐进的非线性访问时间,但实际上是常量访问时间。 * 这样的List实现通常都应该实现该接口。

* 一般来说,某个List实现如果(对某些典型的类的实例来说)满足下面的条件,就应该实现这个接口:循环
* 
 *     for (int i=0, n=list.size(); i < n; i++) *         list.get(i); * 
* runs faster than this loop: * 比下面的循环运行速度快。 *
 *     for (Iterator i=list.iterator(); i.hasNext(); ) *         i.next(); * 
* *

This interface is a member of the * * Java Collections Framework. * 这个接口是Java集合框架的一员。 * @since 1.4 */public interface RandomAccess {}

转载于:https://www.cnblogs.com/zhangyuhang3/p/6909951.html

你可能感兴趣的文章
读《图解HTTP》有感-(返回结果的HTTP状态码)
查看>>
操作数栈
查看>>
转:文本分类问题
查看>>
tensorflow_python中文手册
查看>>
Vs2012在Linux应用程序开发(3):加入新平台hi3516
查看>>
adb shell am 的用法
查看>>
实现自动点击
查看>>
MVP开发模式的理解
查看>>
Unity多开的方法
查看>>
File类中的list()和listFiles()方法
查看>>
我的VS CODE插件配置 主要针对.NET和前端插件配置
查看>>
关于js中的事件
查看>>
一致性哈希算法运用到分布式
查看>>
决策树和随机森林->信息熵和条件熵
查看>>
iOS10 UI教程视图和子视图的可见性
查看>>
Maven学习笔记
查看>>
FindChildControl与FindComponent
查看>>
1、简述在java网络编程中,服务端程序与客户端程序的具体开发步骤?
查看>>
C# Web版报表
查看>>
中国城市json
查看>>