Source Home >> Java Source 1.6.0 >> java.util.RandomAccess V 0.09
  • 01/*
  • 02 * @(#)RandomAccess.java 1.9 06/04/21
  • 03 *
  • 04 * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
  • 05 * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
  • 06 */
  • 07
  • 08package java.util;
  • 09
  • 10/**
  • 11 * Marker interface used by <tt>List</tt> implementations to indicate that
  • 12 * they support fast (generally constant time) random access. The primary
  • 13 * purpose of this interface is to allow generic algorithms to alter their
  • 14 * behavior to provide good performance when applied to either random or
  • 15 * sequential access lists.
  • 16 *
  • 17 * <p>The best algorithms for manipulating random access lists (such as
  • 18 * <tt>ArrayList</tt>) can produce quadratic behavior when applied to
  • 19 * sequential access lists (such as <tt>LinkedList</tt>). Generic list
  • 20 * algorithms are encouraged to check whether the given list is an
  • 21 * <tt>instanceof</tt> this interface before applying an algorithm that would
  • 22 * provide poor performance if it were applied to a sequential access list,
  • 23 * and to alter their behavior if necessary to guarantee acceptable
  • 24 * performance.
  • 25 *
  • 26 * <p>It is recognized that the distinction between random and sequential
  • 27 * access is often fuzzy. For example, some <tt>List</tt> implementations
  • 28 * provide asymptotically linear access times if they get huge, but constant
  • 29 * access times in practice. Such a <tt>List</tt> implementation
  • 30 * should generally implement this interface. As a rule of thumb, a
  • 31 * <tt>List</tt> implementation should implement this interface if,
  • 32 * for typical instances of the class, this loop:
  • 33 * <pre>
  • 34 * for (int i=0, n=list.size(); i < n; i++)
  • 35 * list.get(i);
  • 36 * </pre>
  • 37 * runs faster than this loop:
  • 38 * <pre>
  • 39 * for (Iterator i=list.iterator(); i.hasNext(); )
  • 40 * i.next();
  • 41 * </pre>
  • 42 *
  • 43 * <p>This interface is a member of the
  • 44 * <a href="{@docRoot}/../technotes/guides/collections/index.html">
  • 45 * Java Collections Framework</a>.
  • 46 *
  • 47 * @since 1.4
  • 48 */
  • 49public interface RandomAccess {
  • 50}

文件:RandomAccess.java
包名:java.util
类名:RandomAccess
继承:
接口: