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

Collections class should provide reverseOrder(Comparator)

XMLWordPrintable



      Name: jl125535 Date: 01/28/2003


      FULL PRODUCT VERSION :
      java version "1.4.0_01"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0_01-b03)
      Java HotSpot(TM) Client VM (build 1.4.0_01-b03, mixed mode)

      A DESCRIPTION OF THE PROBLEM :
      The Collections class provides a method (reverseOrder() ) to return a
      Comparator which compares in the opposite order of the natural ordering, but
      does not provide a comparator whose order is the reverse of the order of a
      given Comparator (reverseOrder(Comparator) )

      REPRODUCIBILITY :
      This bug can be reproduced always.

      CUSTOMER WORKAROUND :
      Implement own Comparator to perform this functionality.
      This is trivial, but that doesn't mean it can't be in the
      standard library--For example, the unmodifiable* and
      synchronized* factories of the Collections class are also
      trivial to implement.
      (While you're at it, use a WeakHashMap to map from
      Comparators to their reverse orders to avoid duplicate
      objects. Not that you wouldn't have done so anyways, of
      course.)
      (Review ID: 158662)
      ======================================================================

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

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: