28
28
import java .util .NavigableMap ;
29
29
import java .util .concurrent .ConcurrentSkipListMap ;
30
30
import java .util .concurrent .atomic .AtomicBoolean ;
31
+ import java .util .function .Supplier ;
31
32
import javax .annotation .concurrent .NotThreadSafe ;
32
33
import org .apache .commons .lang .mutable .MutableInt ;
33
- import org .roaringbitmap .RoaringBitSet ;
34
34
35
35
/**
36
36
* A Concurrent set comprising zero or more ranges of type {@link LongPair}. This can be alternative of
@@ -48,6 +48,7 @@ public class OpenLongPairRangeSet<T extends Comparable<T>> implements LongPairRa
48
48
49
49
protected final NavigableMap <Long , BitSet > rangeBitSetMap = new ConcurrentSkipListMap <>();
50
50
private final LongPairConsumer <T > consumer ;
51
+ private final Supplier <BitSet > bitSetSupplier ;
51
52
52
53
// caching place-holder for cpu-optimization to avoid calculating ranges again
53
54
private volatile int cachedSize = 0 ;
@@ -56,7 +57,12 @@ public class OpenLongPairRangeSet<T extends Comparable<T>> implements LongPairRa
56
57
private volatile boolean updatedAfterCachedForToString = true ;
57
58
58
59
public OpenLongPairRangeSet (LongPairConsumer <T > consumer ) {
60
+ this (consumer , BitSet ::new );
61
+ }
62
+
63
+ public OpenLongPairRangeSet (LongPairConsumer <T > consumer , Supplier <BitSet > bitSetSupplier ) {
59
64
this .consumer = consumer ;
65
+ this .bitSetSupplier = bitSetSupplier ;
60
66
}
61
67
62
68
/**
@@ -405,7 +411,7 @@ private int getSafeEntry(long value) {
405
411
}
406
412
407
413
private BitSet createNewBitSet () {
408
- return new RoaringBitSet ();
414
+ return bitSetSupplier . get ();
409
415
}
410
416
411
417
}
0 commit comments