You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by bu...@apache.org on 2004/06/11 10:47:06 UTC
DO NOT REPLY [Bug 29519] New: -
DualTreeBidiMap does not sort with custom Comparator
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