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

Collections framework would benefit from a few additional algorithms

XMLWordPrintable

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

      The Collections utility class would benefit from the addition of
      a few well-chosen algorithms:

      void rotate(List l, int distance) - Rotates all of the elements elements
      clockwise by the the given distance. This operation is common in GUI
      computations: moving one or more columns in a table can be accomplished
      efficiently by applying this operation to a sublist. This operation is
      also common in mathematical and scientific calculations. While very short,
      this operation is difficult to program correctly and efficiently.

      boolean replaceAll(List l, Object oldVal, Object newVal) - Replaces all
      occurences of one specified value with another. This is essentially a
      covenience method. Though not difficult to program, it's very commonly
      needed. Further, our implementation can be faster than end-user
      implementations because it has access to the internals of our collections.

      int indexOfRange(List l, List range)/lastIndexOfRange(List l, List range)
      - Returns the index of the leftmost/rightmost sublist of the specified
      list (l) that is equal the to the specified range. Commonly used in
      many domains including text processing. Surprisingly difficult to
      get this right, even if the "naive" algorithm is used.

            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: