Jdk 接口类RandomAccess了解
1. 接口说明
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)实现使用的标记接口,用于指示它们支持快速(通常是恒定时间)随机访问。该接口的主要目的是允许通用(一般的)算法改变其行为,以便在应用于随机或顺序访问列表时提供良好的性能。
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)当应用在顺序访问列表会产生二次行为(如LinkedList)。鼓励(支持)通用(一般的)列表算法在应用算法之前检查给定的列表是否是该接口的实例,如果将算法应用于顺序访问列表,则该算法将提供较差的性能,并在必要时改变他们的行为,以保证可以接受的性能。
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:
这个循环
    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();
可以使用
public class ArrayList<E> extends AbstractList<E>
implements List<E>, RandomAccess, Cloneable, java.io.Serializable
和
public class LinkedList<E> extends AbstractSequentialList<E>
implements List<E>, Deque<E>, Cloneable, Serializable
测试一下。
Jdk 接口类RandomAccess了解的更多相关文章
- Java 通过getbean取出的类为什么要强转为接口类
		
这个问题是之前一个同学问我的,这些是我在网上找到的资料,由于我自己也没有完全搞明白,先大概记录一下 首先问题是为什么在bean文件中注入的是实现类,但是通过getBean()取出的时候却必须强制转化为 ...
 - C++:如何正确的定义一个接口类
		
C++中如何定义接口类?首先给接口类下了定义:接口类应该是只提供方法声明,而自身不提供方法定义的抽象类.接口类自身不能实例化,接口类的方法定义/实现只能由接口类的子类来完成. 而对于C++,其接口类一 ...
 - java基础2.-------interface接口类,实现接口
		
1.为什么使用接口,是把功能方法都写在一个类中,在其他需要调用的时候,通过implements实现该接口 2.接口可以继承多个父类接口,在实现接口的时候,实现类实现所有方法 3.在接口类写方法时,自动 ...
 - PHP中的特殊类,接口类和抽象类(都不能直接实例化)
		
接口类不用实例化,需要一一实现接口定义的所有方法.关键字interface implements 接口interface 是一个规定,给人继承用的东西,有点像抽象类在里面定义的方法,却不去实例化,而需 ...
 - 调用c++接口类
		
调用c++接口类 public class CarDeviceDll { /*对dll库进行一些初始化*/ [DllImport("IDI.dll")] public static ...
 - 无法将类型为“Excel.ApplicationClass”的 COM 对象强制转换为接口类  型“Excel._Application”。此操作失败的原因是对 IID 为“{000208D5  -0000-0000-C000-000000000046}”的接口的 COM 组件调用   QueryInterface 因以下错误而失败: 加载类型库/DLL 时出错。 (异常来  自 HRESULT:
		
无法将类型为“Excel.ApplicationClass”的 COM 对象强制转换为接口类 型“Excel._Application”.此操作失败的原因是对 IID 为“{000208D5 -000 ...
 - 类,抽象基类,接口类三者间的区别与联系(C++)
		
结构上的区别: 普通类:数据+方法+实现 抽象类:数据+方法(一定包含虚方法n>=1)+部分方法的实现 接口类:方法(纯虚方法) http://www.cnblogs.com/Tris-wu/p ...
 - PHP接口类interface的正确使用方法
		
对于那些初学PHP语言的人来说,对于PHP的接口类也许了解的还不是很深入,接下来我们就来具体讲述PHP接口类interface的使用方法. 如何正确运用PHP XMLReader解析XML文档 深入解 ...
 - PHP的接口类(interface)和抽象类(abstract)的区别
		
<?php /** * 接口类:interface * 其实他们的作用很简单,当有很多人一起开发一个项目时,可能都会去调用别人写的一些类, * 那你就会问,我怎么知道他的某个功能的实现方法是怎么 ...
 
随机推荐
- Cannot set the value of read-only property 'outputFile' for ApkVariantOutputImpl_Decorated{...
			
转载请标明出处:https://www.cnblogs.com/tangZH/p/10764568.html 在做多渠道打包的时候出现了这个错误,在高版本的gradle出现. 具体错误为:Cannot ...
 - 骁龙735处理器细节曝光:7nm工艺加持,支持5G
			
骁龙700系列是高通公司的中高端芯片组系列,该系列包括10nm骁龙710和骁龙712 SoC:以及8nm骁龙730和骁龙730G SoC.最新消息显示,高通公司正在开发一款新的7nm芯片组,将被称为骁 ...
 - Android项目实战(五十四):zxing 生成二维码图片去除白色内边距的解决方案
			
目录:zxing->encoding->EncodingHandler类 中修改 createQRCode方法 private static final int BLACK = 0xff0 ...
 - 【译】MongoDb vs Mysql—以NodeJs为例
			
亲爱的读者,您可能想知道为什么要写关于MongoDb和MySql这篇文章.那是因为我与NodeJs开发人员讨论在应用程序中使用哪种数据存储作为主要的数据存储方式. 我看过很多评论都在争论这个问题. 有 ...
 - sdk和api的区别
			
SDK SDK是Software Development Kit的缩写,中文意思是“软件开发工具包”.这是一个覆盖面相当广泛的名词,可以这么说:辅助开发某一类软件的相关文档.范例和工具的集合都可以叫做 ...
 - LOJ #6060. 「2017 山东一轮集训 Day1 / SDWC2018 Day1」Set
			
有趣的思博套路题,想到了基本上加上个对线性基的理解就可以过了 首先考虑到这个把数分成两半的分别异或的过程不会改变某一位上\(1\)的总个数 因此我们求出所有数的\(\operatorname{xor} ...
 - 跨平台数据库工具Azure Data Studio
			
Azure Data Studio是一种跨平台数据库工具,适用于在Windows,MacOS和Linux上使用Microsoft系列内部部署和云数据平台的数据专业人员.Azure Data Studi ...
 - 6.[leetcode] ZigZag Conversion
			
The string "PAYPALISHIRING" is written in a zigzag pattern on a given number of rows like ...
 - 使用sklearn时cannot import name MLPClassifier的解决办法
			
scikit-learn v0.17只有BernoulliRBM,没有MLPClassifier. 只需要把scikit-learn升级到v0.18即可. 在控制台输入下面任一个命令即可: conda ...
 - [JavaScript] 函数节流(throttle)和函数防抖(debounce)
			
js 的函数节流(throttle)和函数防抖(debounce)概述 函数防抖(debounce) 一个事件频繁触发,但是我们不想让他触发的这么频繁,于是我们就设置一个定时器让这个事件在 xxx 秒 ...