org.roaringbitmap.longlong.LongConsumerRelativeRangeAdapter Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of RoaringBitmap Show documentation
Show all versions of RoaringBitmap Show documentation
Roaring bitmaps are compressed bitmaps (also called bitsets) which tend to outperform
conventional compressed bitmaps such as WAH or Concise.
package org.roaringbitmap.longlong;
import org.roaringbitmap.RelativeRangeConsumer;
/**
* Wrapper to use a LongConsumer where a RelativeRangeConsumer is expected.
*/
public class LongConsumerRelativeRangeAdapter implements RelativeRangeConsumer {
final long start;
final LongConsumer absolutePositionConsumer;
public LongConsumerRelativeRangeAdapter(long start, final LongConsumer lc) {
this.start = start;
this.absolutePositionConsumer = lc;
}
@Override
public void acceptPresent(int relativePos) {
absolutePositionConsumer.accept(start + relativePos);
}
@Override
public void acceptAbsent(int relativePos) {
// nothing to do
}
@Override
public void acceptAllPresent(int relativeFrom, int relativeTo) {
for (long pos = start + relativeFrom; pos < start + relativeTo; pos++) {
absolutePositionConsumer.accept(pos);
}
}
@Override
public void acceptAllAbsent(int relativeFrom, int relativeTo) {
// nothing to do
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy