United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: JDK-4809442 Collections class should provide reverseOrder(Comparator)
JDK-4809442 : Collections class should provide reverseOrder(Comparator)

Details
Type:
Enhancement
Submit Date:
2003-01-28
Status:
Resolved
Updated Date:
2003-08-30
Project Name:
JDK
Resolved Date:
2003-08-30
Component:
core-libs
OS:
windows_xp
Sub-Component:
java.util
CPU:
x86
Priority:
P5
Resolution:
Fixed
Affected Versions:
1.4.0
Fixed Versions:
5.0 (tiger)

Related Reports

Sub Tasks

Description

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) 
======================================================================

                                    

Comments
EVALUATION

A reasonable request, especially as it's easy to get this wrong--it's not sufficient merely to negate the return value, as -Integer.MIN_VALUE is still negative.

###@###.### 2003-01-29
                                     
2003-01-29
CONVERTED DATA

BugTraq+ Release Management Values

COMMIT TO FIX:
tiger

FIXED IN:
tiger

INTEGRATED IN:
tiger
tiger-b18


                                     
2004-06-14



Hardware and Software, Engineered to Work Together