RandomAccess.java 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. /* RandomAccess.java -- A tagging interface that lists can use to tailor
  2. operations to the correct algorithm
  3. Copyright (C) 2001, 2005 Free Software Foundation, Inc.
  4. This file is part of GNU Classpath.
  5. GNU Classpath is free software; you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation; either version 2, or (at your option)
  8. any later version.
  9. GNU Classpath is distributed in the hope that it will be useful, but
  10. WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with GNU Classpath; see the file COPYING. If not, write to the
  15. Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
  16. 02110-1301 USA.
  17. Linking this library statically or dynamically with other modules is
  18. making a combined work based on this library. Thus, the terms and
  19. conditions of the GNU General Public License cover the whole
  20. combination.
  21. As a special exception, the copyright holders of this library give you
  22. permission to link this library with independent modules to produce an
  23. executable, regardless of the license terms of these independent
  24. modules, and to copy and distribute the resulting executable under
  25. terms of your choice, provided that you also meet, for each linked
  26. independent module, the terms and conditions of the license of that
  27. module. An independent module is a module which is not derived from
  28. or based on this library. If you modify this library, you may extend
  29. this exception to your version of the library, but you are not
  30. obligated to do so. If you do not wish to do so, delete this
  31. exception statement from your version. */
  32. package java.util;
  33. /**
  34. * Marker interface used to inform <code>List</code> implementations that
  35. * they support fast (usually constant time) random access. This allows
  36. * generic list algorithms to tailor their behavior based on the list
  37. * type.
  38. * <p>
  39. *
  40. * For example, some sorts are n*log(n) on an array, but decay to quadratic
  41. * time on a linked list. As a rule of thumb, this interface should be
  42. * used is this loop:<br>
  43. * <code>for (int i = 0, n = list.size(); i &lt; n; i++) list.get(i);</code>
  44. * <br>runs faster than this loop:<br>
  45. * <code>for (Iterator i = list.iterator(); i.hasNext(); ) i.next();</code>
  46. *
  47. * @author Eric Blake (ebb9@email.byu.edu)
  48. * @see List
  49. * @since 1.4
  50. * @status updated to 1.4
  51. */
  52. public interface RandomAccess
  53. {
  54. // Tagging interface only.
  55. }