Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4327164

List needs marker interface to advertise random access

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Fixed
    • Icon: P4 P4
    • 1.4.0
    • 1.3.0
    • core-libs
    • None

      The best algorithms for manipulating random access lists (such as ArrayList)
      can produce quadratic behavior when applied to sequential access lists (such
      as LinkedList). For example, there are two algorithms for rotating a list.
      One, based on swaps, runs very quickly on random access lists, but degenerates
      to quadratic behavior on sequential access lists. An alternative algorithm,
      based of reversals, runs in linear time for random or sequential access lists,
      but is seven times slower than the swap algorithm on ArrayList. Many other
      generic algorithms (include binary search and shuffle) have similar problems.

      A marker interface would allow List implementations to indicate
      that they support fast (generally constant time) random access. This would
      allow generic algorithms to alter their behavior to provide good performance
      when applied to either random or sequential access lists.

            jjb Josh Bloch (Inactive)
            jjb Josh Bloch (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: