Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Invalid
-
None
-
None
-
None
Description
ImmutableBitSet should not implement the Comparable interface. Comparable requires a total order – in particular, x.compareTo(y) should return 0 if and only if x.equals(y)} – but {{ImmutableBitSet is a partial order (set inclusion).
Bad things happen if you use non-compliant Comparable}}s as keys in a {{HashMap in JDK 8 or later. It uses a red-black tree and some of the keys just disappear. (I was using ImmutableBitSet as a key within a PartiallyOrderedSet, which has a HashMap inside.)
Remove implements Comparable and add a field public static Comparator<ImmutableBitSet> COMPARATOR instead. People can use it if they know the risks.