@Test public void testSelect_Empty() { assertThrows(IllegalArgumentException.class, () -> { Roaring64NavigableMap map = newUnsignedHeap(); map.select(0); }); }
@Override public long select(final long j) throws IllegalArgumentException { if (!doCacheCardinalities) { return selectNoCache(j); } int indexOk = ensureCumulatives(highestHigh()); if (highToBitmap.isEmpty()) { return throwSelectInvalidIndex(j); } int position = Arrays.binarySearch(sortedCumulatedCardinality, 0, indexOk, j); if (position >= 0) { if (position == indexOk - 1) { return throwSelectInvalidIndex(j); } int high = sortedHighs[position + 1]; BitmapDataProvider nextBitmap = highToBitmap.get(high); return RoaringIntPacking.pack(high, nextBitmap.select(0)); } else { int insertionPoint = -position - 1; final long previousBucketCardinality; if (insertionPoint == 0) { previousBucketCardinality = 0L; } else if (insertionPoint >= indexOk) { return throwSelectInvalidIndex(j); } else { previousBucketCardinality = sortedCumulatedCardinality[insertionPoint - 1]; } final int givenBitmapSelect = (int) (j - previousBucketCardinality); int high = sortedHighs[insertionPoint]; BitmapDataProvider lowBitmap = highToBitmap.get(high); int low = lowBitmap.select(givenBitmapSelect); return RoaringIntPacking.pack(high, low); } }
Roaring64NavigableMap implements Externalizable, LongBitmapDataProvider { @Override public long select(final long j) throws IllegalArgumentException { if (!doCacheCardinalities) { return selectNoCache(j); } int indexOk = ensureCumulatives(highestHigh()); if (highToBitmap.isEmpty()) { return throwSelectInvalidIndex(j); } int position = Arrays.binarySearch(sortedCumulatedCardinality, 0, indexOk, j); if (position >= 0) { if (position == indexOk - 1) { return throwSelectInvalidIndex(j); } int high = sortedHighs[position + 1]; BitmapDataProvider nextBitmap = highToBitmap.get(high); return RoaringIntPacking.pack(high, nextBitmap.select(0)); } else { int insertionPoint = -position - 1; final long previousBucketCardinality; if (insertionPoint == 0) { previousBucketCardinality = 0L; } else if (insertionPoint >= indexOk) { return throwSelectInvalidIndex(j); } else { previousBucketCardinality = sortedCumulatedCardinality[insertionPoint - 1]; } final int givenBitmapSelect = (int) (j - previousBucketCardinality); int high = sortedHighs[insertionPoint]; BitmapDataProvider lowBitmap = highToBitmap.get(high); int low = lowBitmap.select(givenBitmapSelect); return RoaringIntPacking.pack(high, low); } } }
Roaring64NavigableMap implements Externalizable, LongBitmapDataProvider { @Override public long select(final long j) throws IllegalArgumentException { if (!doCacheCardinalities) { return selectNoCache(j); } int indexOk = ensureCumulatives(highestHigh()); if (highToBitmap.isEmpty()) { return throwSelectInvalidIndex(j); } int position = Arrays.binarySearch(sortedCumulatedCardinality, 0, indexOk, j); if (position >= 0) { if (position == indexOk - 1) { return throwSelectInvalidIndex(j); } int high = sortedHighs[position + 1]; BitmapDataProvider nextBitmap = highToBitmap.get(high); return RoaringIntPacking.pack(high, nextBitmap.select(0)); } else { int insertionPoint = -position - 1; final long previousBucketCardinality; if (insertionPoint == 0) { previousBucketCardinality = 0L; } else if (insertionPoint >= indexOk) { return throwSelectInvalidIndex(j); } else { previousBucketCardinality = sortedCumulatedCardinality[insertionPoint - 1]; } final int givenBitmapSelect = (int) (j - previousBucketCardinality); int high = sortedHighs[insertionPoint]; BitmapDataProvider lowBitmap = highToBitmap.get(high); int low = lowBitmap.select(givenBitmapSelect); return RoaringIntPacking.pack(high, low); } } Roaring64NavigableMap();  Roaring64NavigableMap(boolean signedLongs);  Roaring64NavigableMap(boolean signedLongs, boolean cacheCardinalities);  Roaring64NavigableMap(BitmapDataProviderSupplier supplier);  Roaring64NavigableMap(boolean signedLongs, BitmapDataProviderSupplier supplier);  Roaring64NavigableMap(boolean signedLongs, boolean cacheCardinalities,
      BitmapDataProviderSupplier supplier); }
Roaring64NavigableMap implements Externalizable, LongBitmapDataProvider { @Override public long select(final long j) throws IllegalArgumentException { if (!doCacheCardinalities) { return selectNoCache(j); } int indexOk = ensureCumulatives(highestHigh()); if (highToBitmap.isEmpty()) { return throwSelectInvalidIndex(j); } int position = Arrays.binarySearch(sortedCumulatedCardinality, 0, indexOk, j); if (position >= 0) { if (position == indexOk - 1) { return throwSelectInvalidIndex(j); } int high = sortedHighs[position + 1]; BitmapDataProvider nextBitmap = highToBitmap.get(high); return RoaringIntPacking.pack(high, nextBitmap.select(0)); } else { int insertionPoint = -position - 1; final long previousBucketCardinality; if (insertionPoint == 0) { previousBucketCardinality = 0L; } else if (insertionPoint >= indexOk) { return throwSelectInvalidIndex(j); } else { previousBucketCardinality = sortedCumulatedCardinality[insertionPoint - 1]; } final int givenBitmapSelect = (int) (j - previousBucketCardinality); int high = sortedHighs[insertionPoint]; BitmapDataProvider lowBitmap = highToBitmap.get(high); int low = lowBitmap.select(givenBitmapSelect); return RoaringIntPacking.pack(high, low); } } Roaring64NavigableMap();  Roaring64NavigableMap(boolean signedLongs);  Roaring64NavigableMap(boolean signedLongs, boolean cacheCardinalities);  Roaring64NavigableMap(BitmapDataProviderSupplier supplier);  Roaring64NavigableMap(boolean signedLongs, BitmapDataProviderSupplier supplier);  Roaring64NavigableMap(boolean signedLongs, boolean cacheCardinalities,
      BitmapDataProviderSupplier supplier); @Override void addLong(long x); void addInt(int x); @Override long getLongCardinality(); int getIntCardinality(); @Override long select(final long j); Iterator<Long> iterator(); @Override void forEach(final LongConsumer lc); @Override long rankLong(long id); void or(final Roaring64NavigableMap x2); void xor(final Roaring64NavigableMap x2); void and(final Roaring64NavigableMap x2); void andNot(final Roaring64NavigableMap x2); @Override void writeExternal(ObjectOutput out); @Override void readExternal(ObjectInput in); @Override String toString(); @Override LongIterator getLongIterator(); @Override boolean contains(long x); @Override int getSizeInBytes(); @Override long getLongSizeInBytes(); @Override boolean isEmpty(); @Override ImmutableLongBitmapDataProvider limit(long x); boolean runOptimize(); @Override void serialize(DataOutput out); void deserialize(DataInput in); @Override long serializedSizeInBytes(); void clear(); @Override long[] toArray(); static Roaring64NavigableMap bitmapOf(final long... dat); void add(long... dat); void add(final long rangeStart, final long rangeEnd); @Override LongIterator getReverseLongIterator(); @Override void removeLong(long x); @Override void trim(); @Override int hashCode(); @Override boolean equals(Object obj); void flip(final long x); }
Roaring64NavigableMap implements Externalizable, LongBitmapDataProvider { @Override public long select(final long j) throws IllegalArgumentException { if (!doCacheCardinalities) { return selectNoCache(j); } int indexOk = ensureCumulatives(highestHigh()); if (highToBitmap.isEmpty()) { return throwSelectInvalidIndex(j); } int position = Arrays.binarySearch(sortedCumulatedCardinality, 0, indexOk, j); if (position >= 0) { if (position == indexOk - 1) { return throwSelectInvalidIndex(j); } int high = sortedHighs[position + 1]; BitmapDataProvider nextBitmap = highToBitmap.get(high); return RoaringIntPacking.pack(high, nextBitmap.select(0)); } else { int insertionPoint = -position - 1; final long previousBucketCardinality; if (insertionPoint == 0) { previousBucketCardinality = 0L; } else if (insertionPoint >= indexOk) { return throwSelectInvalidIndex(j); } else { previousBucketCardinality = sortedCumulatedCardinality[insertionPoint - 1]; } final int givenBitmapSelect = (int) (j - previousBucketCardinality); int high = sortedHighs[insertionPoint]; BitmapDataProvider lowBitmap = highToBitmap.get(high); int low = lowBitmap.select(givenBitmapSelect); return RoaringIntPacking.pack(high, low); } } Roaring64NavigableMap();  Roaring64NavigableMap(boolean signedLongs);  Roaring64NavigableMap(boolean signedLongs, boolean cacheCardinalities);  Roaring64NavigableMap(BitmapDataProviderSupplier supplier);  Roaring64NavigableMap(boolean signedLongs, BitmapDataProviderSupplier supplier);  Roaring64NavigableMap(boolean signedLongs, boolean cacheCardinalities,
      BitmapDataProviderSupplier supplier); @Override void addLong(long x); void addInt(int x); @Override long getLongCardinality(); int getIntCardinality(); @Override long select(final long j); Iterator<Long> iterator(); @Override void forEach(final LongConsumer lc); @Override long rankLong(long id); void or(final Roaring64NavigableMap x2); void xor(final Roaring64NavigableMap x2); void and(final Roaring64NavigableMap x2); void andNot(final Roaring64NavigableMap x2); @Override void writeExternal(ObjectOutput out); @Override void readExternal(ObjectInput in); @Override String toString(); @Override LongIterator getLongIterator(); @Override boolean contains(long x); @Override int getSizeInBytes(); @Override long getLongSizeInBytes(); @Override boolean isEmpty(); @Override ImmutableLongBitmapDataProvider limit(long x); boolean runOptimize(); @Override void serialize(DataOutput out); void deserialize(DataInput in); @Override long serializedSizeInBytes(); void clear(); @Override long[] toArray(); static Roaring64NavigableMap bitmapOf(final long... dat); void add(long... dat); void add(final long rangeStart, final long rangeEnd); @Override LongIterator getReverseLongIterator(); @Override void removeLong(long x); @Override void trim(); @Override int hashCode(); @Override boolean equals(Object obj); void flip(final long x);  }