public interface RandomAccess
操纵随机存取列表最好的算法(如ArrayList)可以应用于顺序访问表二次行为产生(如LinkedList)。通用链表算法,鼓励检查是否给定的列表是一个instanceof这个接口之前采用的算法,如果是应用于顺序访问列表提供性能较差,并在必要时保证可接受的性能改变他们的行为。
它是公认的随机和顺序访问之间的区别往往是模糊的。例如,一些List实现提供渐近线性访问时间如果他们得到巨大的,但在实践中不断的访问时间。这样的List一般应实现此接口的实现。作为一个经验法则,一个List实施应实现此接口,如果类的典型实例,这个循环:
为(int i = 0,n =列表。size();i < n;i++)列表。获取(I);跑得比这更快:
对(我=列表迭代器。();我hasnext();)我next();
该接口的 Java Collections Framework成员。
环 Submit a bug or feature
For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
Copyright © 1993, 2014, Oracle and/or its affiliates. All rights reserved.