commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 29519] New: - DualTreeBidiMap does not sort with custom Comparator
Date Fri, 11 Jun 2004 08:47:06 GMT
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=29519>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=29519

DualTreeBidiMap does not  sort with custom Comparator

           Summary: DualTreeBidiMap does not  sort with custom Comparator
           Product: Commons
           Version: 3.0 Final
          Platform: Other
        OS/Version: Other
            Status: NEW
          Severity: Major
          Priority: Other
         Component: Collections
        AssignedTo: commons-dev@jakarta.apache.org
        ReportedBy: Jonas.VanPoucke@actonomy.com


When you supply a Comparator to the constructor of DualTreeBidiMap, the custom
sorting order is NOT maintained. 

The problem lies in the order where 
    protected Map createMap()
is called: The constructors in AbstractDualBidiMap call this metod, but the
comparator is set *after* calling super() in DualTreeBidiMap:

//--- Class AbstractDualBidiMap---// 
    protected AbstractDualBidiMap() {
        super();
        maps[0] = createMap();
        maps[1] = createMap();
    }
//--- Class DualTreeBidiMap ---// 
    public DualTreeBidiMap(Comparator comparator) {
        super();
        this.comparator = comparator; // <-- Too late, createMap already called!
    }
    protected Map createMap() {
        return new TreeMap(comparator); // <-- Comparator always null
    }


Hence, DualTreeBidiMap.compatator() always returns null.

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message