use of org.roaringbitmap.IntConsumer in project RoaringBitmap by RoaringBitmap.
the class MapBenchmark method testMapViaBitset.
@BenchmarkMode(Mode.AverageTime)
@Benchmark
public RoaringBitmap testMapViaBitset(BenchmarkState benchmarkState) {
final BitSet altRes = new java.util.BitSet();
benchmarkState.bitmap.forEach(new IntConsumer() {
@Override
public void accept(int value) {
altRes.set(inttointmap(value));
}
});
return BitSetUtil.bitmapOf(altRes);
}
use of org.roaringbitmap.IntConsumer in project RoaringBitmap by RoaringBitmap.
the class MutableInteger method testSparse.
@Test
public void testSparse() {
MutableRoaringBitmap bitmap = new MutableRoaringBitmap();
for (int k = 0; k < 100000; k += 3000) bitmap.add(k);
final MutableInteger cardinality = new MutableInteger();
bitmap.forEach(new IntConsumer() {
int expected = 0;
@Override
public void accept(int value) {
cardinality.value++;
Assert.assertEquals(value, expected);
expected += 3000;
}
});
Assert.assertEquals(cardinality.value, bitmap.getCardinality());
}
use of org.roaringbitmap.IntConsumer in project RoaringBitmap by RoaringBitmap.
the class MutableInteger method testContinuous.
@Test
public void testContinuous() {
MutableRoaringBitmap bitmap = new MutableRoaringBitmap();
bitmap.add(100L, 10000L);
final MutableInteger cardinality = new MutableInteger();
bitmap.forEach(new IntConsumer() {
int expected = 100;
@Override
public void accept(int value) {
cardinality.value++;
Assert.assertEquals(value, expected++);
}
});
Assert.assertEquals(cardinality.value, bitmap.getCardinality());
}
use of org.roaringbitmap.IntConsumer in project RoaringBitmap by RoaringBitmap.
the class TestMappeableBitmapContainer method foreach.
@Test
public void foreach() {
LongBuffer buffer = LongBuffer.allocate(MAX_CAPACITY / 64);
buffer.put(~0L);
MappeableContainer bc = new MappeableBitmapContainer(buffer.asReadOnlyBuffer(), 64);
bc.forEach((short) 0, new IntConsumer() {
int expected = 0;
@Override
public void accept(int value) {
assertEquals(value, expected++);
}
});
}
use of org.roaringbitmap.IntConsumer in project RoaringBitmap by RoaringBitmap.
the class MutableInteger method testDense.
@Test
public void testDense() {
MutableRoaringBitmap bitmap = new MutableRoaringBitmap();
for (int k = 0; k < 100000; k += 3) bitmap.add(k);
final MutableInteger cardinality = new MutableInteger();
bitmap.forEach(new IntConsumer() {
int expected = 0;
@Override
public void accept(int value) {
cardinality.value++;
Assert.assertEquals(value, expected);
expected += 3;
}
});
Assert.assertEquals(cardinality.value, bitmap.getCardinality());
}
Aggregations