@Test public void foreach() { LongBuffer buffer = LongBuffer.allocate(MAX_CAPACITY / 64); buffer.put(~0L); MappeableContainer bc = new MappeableBitmapContainer(buffer.asReadOnlyBuffer(), 64); bc.forEach((char) 0, new IntConsumer() { int expected = 0; @Override public void accept(int value) { assertEquals(value, expected++); } }); }
@Override public void forEach(char msb, IntConsumer ic) { int high = ((int) msb) << 16; if (BufferUtil.isBackedBySimpleArray(bitmap)) { long[] b = bitmap.array(); for (int x = 0; x < b.length; ++x) { long w = b[x]; while (w != 0) { ic.accept((x * 64 + numberOfTrailingZeros(w)) | high); w &= (w - 1); } } } else { int l = bitmap.limit(); for (int x = 0; x < l; ++x) { long w = bitmap.get(x); while (w != 0) { ic.accept((x * 64 + numberOfTrailingZeros(w)) | high); w &= (w - 1); } } } }
MappeableBitmapContainer extends MappeableContainer implements Cloneable { @Override public void forEach(char msb, IntConsumer ic) { int high = ((int) msb) << 16; if (BufferUtil.isBackedBySimpleArray(bitmap)) { long[] b = bitmap.array(); for (int x = 0; x < b.length; ++x) { long w = b[x]; while (w != 0) { ic.accept((x * 64 + numberOfTrailingZeros(w)) | high); w &= (w - 1); } } } else { int l = bitmap.limit(); for (int x = 0; x < l; ++x) { long w = bitmap.get(x); while (w != 0) { ic.accept((x * 64 + numberOfTrailingZeros(w)) | high); w &= (w - 1); } } } } }
MappeableBitmapContainer extends MappeableContainer implements Cloneable { @Override public void forEach(char msb, IntConsumer ic) { int high = ((int) msb) << 16; if (BufferUtil.isBackedBySimpleArray(bitmap)) { long[] b = bitmap.array(); for (int x = 0; x < b.length; ++x) { long w = b[x]; while (w != 0) { ic.accept((x * 64 + numberOfTrailingZeros(w)) | high); w &= (w - 1); } } } else { int l = bitmap.limit(); for (int x = 0; x < l; ++x) { long w = bitmap.get(x); while (w != 0) { ic.accept((x * 64 + numberOfTrailingZeros(w)) | high); w &= (w - 1); } } } } MappeableBitmapContainer();  MappeableBitmapContainer(BitmapContainer bc);  MappeableBitmapContainer(final int firstOfRun, final int lastOfRun);   MappeableBitmapContainer(int newCardinality, LongBuffer newBitmap);  MappeableBitmapContainer(final LongBuffer array, final int initCardinality); }
MappeableBitmapContainer extends MappeableContainer implements Cloneable { @Override public void forEach(char msb, IntConsumer ic) { int high = ((int) msb) << 16; if (BufferUtil.isBackedBySimpleArray(bitmap)) { long[] b = bitmap.array(); for (int x = 0; x < b.length; ++x) { long w = b[x]; while (w != 0) { ic.accept((x * 64 + numberOfTrailingZeros(w)) | high); w &= (w - 1); } } } else { int l = bitmap.limit(); for (int x = 0; x < l; ++x) { long w = bitmap.get(x); while (w != 0) { ic.accept((x * 64 + numberOfTrailingZeros(w)) | high); w &= (w - 1); } } } } MappeableBitmapContainer();  MappeableBitmapContainer(BitmapContainer bc);  MappeableBitmapContainer(final int firstOfRun, final int lastOfRun);   MappeableBitmapContainer(int newCardinality, LongBuffer newBitmap);  MappeableBitmapContainer(final LongBuffer array, final int initCardinality); @Override MappeableContainer add(int begin, int end); @Override MappeableContainer add(final char i); @Override boolean isEmpty(); @Override MappeableArrayContainer and(final MappeableArrayContainer value2); @Override MappeableContainer and(final MappeableBitmapContainer value2); @Override MappeableContainer and(final MappeableRunContainer value2); @Override MappeableContainer andNot(final MappeableArrayContainer value2); @Override MappeableContainer andNot(final MappeableBitmapContainer value2); @Override MappeableContainer andNot(final MappeableRunContainer value2); @Override void clear(); @Override MappeableBitmapContainer clone(); @Override boolean contains(final char i); static boolean contains(ByteBuffer buf, int position, final char i); @Override boolean equals(Object o); @Override void fillLeastSignificant16bits(int[] x, int i, int mask); @Override MappeableContainer flip(char i); @Override int getCardinality(); @Override CharIterator getReverseCharIterator(); @Override PeekableCharIterator getCharIterator(); @Override ContainerBatchIterator getBatchIterator(); @Override int getSizeInBytes(); @Override int hashCode(); @Override MappeableContainer iadd(int begin, int end); @Override MappeableContainer iand(final MappeableArrayContainer b2); @Override MappeableContainer iand(final MappeableBitmapContainer b2); @Override MappeableContainer iand(final MappeableRunContainer x); @Override MappeableContainer iandNot(final MappeableArrayContainer b2); @Override MappeableContainer iandNot(final MappeableBitmapContainer b2); @Override MappeableContainer iandNot(final MappeableRunContainer x); @Override MappeableContainer inot(final int firstOfRange, final int lastOfRange); @Override boolean intersects(MappeableArrayContainer value2); @Override boolean intersects(MappeableBitmapContainer value2); @Override boolean intersects(MappeableRunContainer x); @Override MappeableBitmapContainer ior(final MappeableArrayContainer value2); @Override MappeableContainer ior(final MappeableBitmapContainer b2); @Override boolean isFull(); @Override MappeableContainer ior(final MappeableRunContainer x); @Override MappeableContainer iremove(int begin, int end); @Override Iterator<Character> iterator(); @Override MappeableContainer ixor(final MappeableArrayContainer value2); @Override MappeableContainer ixor(MappeableBitmapContainer b2); @Override MappeableContainer ixor(final MappeableRunContainer x); @Override MappeableContainer limit(int maxcardinality); int nextSetBit(final int i); @Override MappeableContainer not(final int firstOfRange, final int lastOfRange); @Override MappeableContainer or(final MappeableArrayContainer value2); @Override MappeableContainer or(final MappeableBitmapContainer value2); @Override MappeableContainer or(final MappeableRunContainer value2); @Override int rank(char lowbits); @Override void readExternal(ObjectInput in); @Override MappeableContainer remove(int begin, int end); @Override MappeableContainer remove(final char i); @Override MappeableContainer repairAfterLazy(); @Override MappeableContainer runOptimize(); @Override char select(int j); @Override int serializedSizeInBytes(); @Override Container toContainer(); long[] toLongArray(); @Override String toString(); @Override void trim(); @Override void writeExternal(ObjectOutput out); @Override MappeableContainer xor(final MappeableArrayContainer value2); @Override MappeableContainer xor(MappeableBitmapContainer value2); @Override MappeableContainer xor(final MappeableRunContainer value2); @Override void forEach(char msb, IntConsumer ic); @Override int andCardinality(final MappeableArrayContainer value2); @Override int andCardinality(final MappeableBitmapContainer value2); @Override int andCardinality(MappeableRunContainer x); @Override MappeableBitmapContainer toBitmapContainer(); @Override int first(); @Override int last(); @Override int nextValue(char fromValue); @Override int previousValue(char fromValue); @Override int nextAbsentValue(char fromValue); @Override int previousAbsentValue(char fromValue); @Override boolean intersects(int minimum, int supremum); @Override boolean contains(int minimum, int supremum); }
MappeableBitmapContainer extends MappeableContainer implements Cloneable { @Override public void forEach(char msb, IntConsumer ic) { int high = ((int) msb) << 16; if (BufferUtil.isBackedBySimpleArray(bitmap)) { long[] b = bitmap.array(); for (int x = 0; x < b.length; ++x) { long w = b[x]; while (w != 0) { ic.accept((x * 64 + numberOfTrailingZeros(w)) | high); w &= (w - 1); } } } else { int l = bitmap.limit(); for (int x = 0; x < l; ++x) { long w = bitmap.get(x); while (w != 0) { ic.accept((x * 64 + numberOfTrailingZeros(w)) | high); w &= (w - 1); } } } } MappeableBitmapContainer();  MappeableBitmapContainer(BitmapContainer bc);  MappeableBitmapContainer(final int firstOfRun, final int lastOfRun);   MappeableBitmapContainer(int newCardinality, LongBuffer newBitmap);  MappeableBitmapContainer(final LongBuffer array, final int initCardinality); @Override MappeableContainer add(int begin, int end); @Override MappeableContainer add(final char i); @Override boolean isEmpty(); @Override MappeableArrayContainer and(final MappeableArrayContainer value2); @Override MappeableContainer and(final MappeableBitmapContainer value2); @Override MappeableContainer and(final MappeableRunContainer value2); @Override MappeableContainer andNot(final MappeableArrayContainer value2); @Override MappeableContainer andNot(final MappeableBitmapContainer value2); @Override MappeableContainer andNot(final MappeableRunContainer value2); @Override void clear(); @Override MappeableBitmapContainer clone(); @Override boolean contains(final char i); static boolean contains(ByteBuffer buf, int position, final char i); @Override boolean equals(Object o); @Override void fillLeastSignificant16bits(int[] x, int i, int mask); @Override MappeableContainer flip(char i); @Override int getCardinality(); @Override CharIterator getReverseCharIterator(); @Override PeekableCharIterator getCharIterator(); @Override ContainerBatchIterator getBatchIterator(); @Override int getSizeInBytes(); @Override int hashCode(); @Override MappeableContainer iadd(int begin, int end); @Override MappeableContainer iand(final MappeableArrayContainer b2); @Override MappeableContainer iand(final MappeableBitmapContainer b2); @Override MappeableContainer iand(final MappeableRunContainer x); @Override MappeableContainer iandNot(final MappeableArrayContainer b2); @Override MappeableContainer iandNot(final MappeableBitmapContainer b2); @Override MappeableContainer iandNot(final MappeableRunContainer x); @Override MappeableContainer inot(final int firstOfRange, final int lastOfRange); @Override boolean intersects(MappeableArrayContainer value2); @Override boolean intersects(MappeableBitmapContainer value2); @Override boolean intersects(MappeableRunContainer x); @Override MappeableBitmapContainer ior(final MappeableArrayContainer value2); @Override MappeableContainer ior(final MappeableBitmapContainer b2); @Override boolean isFull(); @Override MappeableContainer ior(final MappeableRunContainer x); @Override MappeableContainer iremove(int begin, int end); @Override Iterator<Character> iterator(); @Override MappeableContainer ixor(final MappeableArrayContainer value2); @Override MappeableContainer ixor(MappeableBitmapContainer b2); @Override MappeableContainer ixor(final MappeableRunContainer x); @Override MappeableContainer limit(int maxcardinality); int nextSetBit(final int i); @Override MappeableContainer not(final int firstOfRange, final int lastOfRange); @Override MappeableContainer or(final MappeableArrayContainer value2); @Override MappeableContainer or(final MappeableBitmapContainer value2); @Override MappeableContainer or(final MappeableRunContainer value2); @Override int rank(char lowbits); @Override void readExternal(ObjectInput in); @Override MappeableContainer remove(int begin, int end); @Override MappeableContainer remove(final char i); @Override MappeableContainer repairAfterLazy(); @Override MappeableContainer runOptimize(); @Override char select(int j); @Override int serializedSizeInBytes(); @Override Container toContainer(); long[] toLongArray(); @Override String toString(); @Override void trim(); @Override void writeExternal(ObjectOutput out); @Override MappeableContainer xor(final MappeableArrayContainer value2); @Override MappeableContainer xor(MappeableBitmapContainer value2); @Override MappeableContainer xor(final MappeableRunContainer value2); @Override void forEach(char msb, IntConsumer ic); @Override int andCardinality(final MappeableArrayContainer value2); @Override int andCardinality(final MappeableBitmapContainer value2); @Override int andCardinality(MappeableRunContainer x); @Override MappeableBitmapContainer toBitmapContainer(); @Override int first(); @Override int last(); @Override int nextValue(char fromValue); @Override int previousValue(char fromValue); @Override int nextAbsentValue(char fromValue); @Override int previousAbsentValue(char fromValue); @Override boolean intersects(int minimum, int supremum); @Override boolean contains(int minimum, int supremum);  }