Uploaded image for project: 'Calcite'
  1. Calcite
  2. CALCITE-1735

ImmutableBitSet should not implement Comparable

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Invalid
    • None
    • 1.13.0
    • 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.

      Attachments

        Activity

          People

            julianhyde Julian Hyde
            julianhyde Julian Hyde
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: