Back to index

plt-scheme  4.2.1
java.util.RandomAccess Interface Reference

Marker interface used to inform List implementations that they support fast (usually constant time) random access. More...

Inheritance diagram for java.util.RandomAccess:
Inheritance graph
[legend]

Detailed Description

Marker interface used to inform List implementations that they support fast (usually constant time) random access.

This allows generic list algorithms to tailor their behavior based on the list type.

For example, some sorts are n*log(n) on an array, but decay to quadratic time on a linked list. As a rule of thumb, this interface should be used is 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();

Author:
Eric Blake ebb9@.nosp@m.emai.nosp@m.l.byu.nosp@m..edu
See also:
List
Since:
1.4 updated to 1.4

Definition at line 61 of file RandomAccess.java.


The documentation for this interface was generated from the following file: