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