public class MutableRoaringBitmap extends ImmutableRoaringBitmap implements Cloneable, Serializable, Iterable<Integer>, Externalizable, BitmapDataProvider
import org.roaringbitmap.buffer.*;
//...
MutableRoaringBitmap rr = MutableRoaringBitmap.bitmapOf(1,2,3,1000);
MutableRoaringBitmap rr2 = new MutableRoaringBitmap();
for(int k = 4000; k<4255;++k) rr2.add(k);
RoaringBitmap rror = RoaringBitmap.or(rr, rr2);
//...
DataOutputStream wheretoserialize = ...
rr.runOptimize(); // can help compression
rr.serialize(wheretoserialize);
ImmutableRoaringBitmap
,
RoaringBitmap
,
Serialized FormConstructor and Description |
---|
MutableRoaringBitmap()
Create an empty bitmap
|
MutableRoaringBitmap(RoaringBitmap rb)
Create a MutableRoaringBitmap from a RoaringBitmap.
|
Modifier and Type | Method and Description |
---|---|
void |
add(int x)
Add the value to the container (set the value to "true"), whether it already appears or not.
|
void |
add(int rangeStart,
int rangeEnd)
Deprecated.
use the version where longs specify the range
|
void |
add(long rangeStart,
long rangeEnd)
Add to the current bitmap all integers in [rangeStart,rangeEnd).
|
static MutableRoaringBitmap |
add(MutableRoaringBitmap rb,
int rangeStart,
int rangeEnd)
Deprecated.
use the version where longs specify the range
|
static MutableRoaringBitmap |
add(MutableRoaringBitmap rb,
long rangeStart,
long rangeEnd)
Generate a new bitmap with all integers in [rangeStart,rangeEnd) added.
|
void |
and(ImmutableRoaringBitmap array)
In-place bitwise AND (intersection) operation.
|
static MutableRoaringBitmap |
and(MutableRoaringBitmap x1,
MutableRoaringBitmap x2)
Bitwise AND (intersection) operation.
|
void |
andNot(ImmutableRoaringBitmap x2)
In-place bitwise ANDNOT (difference) operation.
|
static MutableRoaringBitmap |
andNot(MutableRoaringBitmap x1,
MutableRoaringBitmap x2)
Bitwise ANDNOT (difference) operation.
|
static MutableRoaringBitmap |
bitmapOf(int... dat)
Generate a bitmap with the specified values set to true.
|
boolean |
checkedAdd(int x)
Add the value to the container (set the value to "true"), whether it already appears or not.
|
boolean |
checkedRemove(int x)
If present remove the specified integer (effectively, sets its bit value to false)
|
void |
clear()
reset to an empty bitmap; result occupies as much space a newly created bitmap.
|
MutableRoaringBitmap |
clone() |
void |
deserialize(DataInput in)
Deserialize the bitmap (retrieve from the input stream).
|
void |
flip(int x)
Add the value if it is not already present, otherwise remove it.
|
void |
flip(int rangeStart,
int rangeEnd)
Deprecated.
use the version where longs specify the range
|
void |
flip(long rangeStart,
long rangeEnd)
Modifies the current bitmap by complementing the bits in the given range, from rangeStart
(inclusive) rangeEnd (exclusive).
|
static MutableRoaringBitmap |
flip(MutableRoaringBitmap rb,
int rangeStart,
int rangeEnd)
Deprecated.
use the version where longs specify the range
|
static MutableRoaringBitmap |
flip(MutableRoaringBitmap bm,
long rangeStart,
long rangeEnd)
Complements the bits in the given range, from rangeStart (inclusive) rangeEnd (exclusive).
|
MutableRoaringArray |
getMappeableRoaringArray() |
int |
hashCode() |
Iterator<Integer> |
iterator()
iterate over the positions of the true values.
|
protected void |
lazyor(ImmutableRoaringBitmap x2) |
protected static MutableRoaringBitmap |
lazyorfromlazyinputs(MutableRoaringBitmap x1,
MutableRoaringBitmap x2) |
static long |
maximumSerializedSize(int cardinality,
int universe_size)
Assume that one wants to store "cardinality" integers in [0, universe_size),
this function returns an upper bound on the serialized size in bytes.
|
protected void |
naivelazyor(ImmutableRoaringBitmap x2) |
static MutableRoaringBitmap |
or(ImmutableRoaringBitmap... bitmaps)
Compute overall OR between bitmaps.
|
void |
or(ImmutableRoaringBitmap x2)
In-place bitwise OR (union) operation.
|
static MutableRoaringBitmap |
or(MutableRoaringBitmap x1,
MutableRoaringBitmap x2)
Bitwise OR (union) operation.
|
protected static void |
rangeSanityCheck(long rangeStart,
long rangeEnd) |
void |
readExternal(ObjectInput in) |
void |
remove(int x)
If present remove the specified integers (effectively, sets its bit value to false)
|
void |
remove(int rangeStart,
int rangeEnd)
Deprecated.
use the version where longs specify the range
|
void |
remove(long rangeStart,
long rangeEnd)
Remove from the current bitmap all integers in [rangeStart,rangeEnd).
|
static MutableRoaringBitmap |
remove(MutableRoaringBitmap rb,
int rangeStart,
int rangeEnd)
Deprecated.
use the version where longs specify the range
|
static MutableRoaringBitmap |
remove(MutableRoaringBitmap rb,
long rangeStart,
long rangeEnd)
Generate a new bitmap with all integers in [rangeStart,rangeEnd) removed.
|
boolean |
removeRunCompression()
Remove run-length encoding even when it is more space efficient
|
protected void |
repairAfterLazy() |
boolean |
runOptimize()
Use a run-length encoding where it is estimated as more space efficient
|
ImmutableRoaringBitmap |
toImmutableRoaringBitmap()
Convenience method, effectively casts the object to an object of class ImmutableRoaringBitmap.
|
void |
trim()
Recover allocated but unused memory.
|
void |
writeExternal(ObjectOutput out) |
void |
xor(ImmutableRoaringBitmap x2)
In-place bitwise XOR (symmetric difference) operation.
|
static MutableRoaringBitmap |
xor(MutableRoaringBitmap x1,
MutableRoaringBitmap x2)
Bitwise XOR (symmetric difference) operation.
|
and, and, and, andCardinality, andNot, andNot, andNot, contains, equals, flip, flip, forEach, getCardinality, getContainerPointer, getIntIterator, getLongCardinality, getLongSizeInBytes, getReverseIntIterator, getSizeInBytes, hasRunCompression, intersects, isEmpty, lazyor, limit, or, or, or, or, orCardinality, rank, rankLong, select, serialize, serializedSizeInBytes, toArray, toMutableRoaringBitmap, toRoaringBitmap, toString, xor, xor, xor
finalize, getClass, notify, notifyAll, wait, wait, wait
forEach, spliterator
select
contains, forEach, getCardinality, getIntIterator, getLongCardinality, getLongSizeInBytes, getReverseIntIterator, getSizeInBytes, isEmpty, limit, rank, rankLong, serialize, serializedSizeInBytes, toArray
public MutableRoaringBitmap()
public MutableRoaringBitmap(RoaringBitmap rb)
rb
- the original bitmappublic static MutableRoaringBitmap add(MutableRoaringBitmap rb, long rangeStart, long rangeEnd)
rb
- initial bitmap (will not be modified)rangeStart
- inclusive beginning of rangerangeEnd
- exclusive ending of range@Deprecated public static MutableRoaringBitmap add(MutableRoaringBitmap rb, int rangeStart, int rangeEnd)
rb
- initial bitmap (will not be modified)rangeStart
- inclusive beginning of rangerangeEnd
- exclusive ending of rangepublic static MutableRoaringBitmap and(MutableRoaringBitmap x1, MutableRoaringBitmap x2)
x1
- first bitmapx2
- other bitmappublic static MutableRoaringBitmap andNot(MutableRoaringBitmap x1, MutableRoaringBitmap x2)
x1
- first bitmapx2
- other bitmappublic static MutableRoaringBitmap bitmapOf(int... dat)
dat
- set valuesprotected static void rangeSanityCheck(long rangeStart, long rangeEnd)
public static MutableRoaringBitmap flip(MutableRoaringBitmap bm, long rangeStart, long rangeEnd)
bm
- bitmap being negatedrangeStart
- inclusive beginning of rangerangeEnd
- exclusive ending of range@Deprecated public static MutableRoaringBitmap flip(MutableRoaringBitmap rb, int rangeStart, int rangeEnd)
rb
- bitmap being negatedrangeStart
- inclusive beginning of rangerangeEnd
- exclusive ending of rangeprotected static MutableRoaringBitmap lazyorfromlazyinputs(MutableRoaringBitmap x1, MutableRoaringBitmap x2)
public static MutableRoaringBitmap or(ImmutableRoaringBitmap... bitmaps)
BufferFastAggregation.or(org.roaringbitmap.buffer.ImmutableRoaringBitmap...)
)bitmaps
- input bitmapspublic static MutableRoaringBitmap or(MutableRoaringBitmap x1, MutableRoaringBitmap x2)
x1
- first bitmapx2
- other bitmappublic static MutableRoaringBitmap remove(MutableRoaringBitmap rb, long rangeStart, long rangeEnd)
rb
- initial bitmap (will not be modified)rangeStart
- inclusive beginning of rangerangeEnd
- exclusive ending of range@Deprecated public static MutableRoaringBitmap remove(MutableRoaringBitmap rb, int rangeStart, int rangeEnd)
rb
- initial bitmap (will not be modified)rangeStart
- inclusive beginning of rangerangeEnd
- exclusive ending of rangepublic static MutableRoaringBitmap xor(MutableRoaringBitmap x1, MutableRoaringBitmap x2)
x1
- first bitmapx2
- other bitmappublic void add(int x)
add
in interface BitmapDataProvider
x
- integer valuepublic void add(long rangeStart, long rangeEnd)
rangeStart
- inclusive beginning of rangerangeEnd
- exclusive ending of range@Deprecated public void add(int rangeStart, int rangeEnd)
rangeStart
- inclusive beginning of rangerangeEnd
- exclusive ending of rangepublic void and(ImmutableRoaringBitmap array)
array
- other bitmappublic void andNot(ImmutableRoaringBitmap x2)
x2
- other bitmappublic boolean checkedAdd(int x)
x
- integer valuepublic boolean checkedRemove(int x)
x
- integer value representing the index in a bitmappublic void clear()
public MutableRoaringBitmap clone()
clone
in class ImmutableRoaringBitmap
public void deserialize(DataInput in) throws IOException
in
- the DataInput streamIOException
- Signals that an I/O exception has occurred.public void flip(int x)
x
- integer valuepublic void flip(long rangeStart, long rangeEnd)
rangeStart
- inclusive beginning of rangerangeEnd
- exclusive ending of range@Deprecated public void flip(int rangeStart, int rangeEnd)
rangeStart
- inclusive beginning of rangerangeEnd
- exclusive ending of rangepublic MutableRoaringArray getMappeableRoaringArray()
public int hashCode()
hashCode
in class ImmutableRoaringBitmap
public Iterator<Integer> iterator()
iterator
in interface Iterable<Integer>
iterator
in class ImmutableRoaringBitmap
protected void lazyor(ImmutableRoaringBitmap x2)
protected void naivelazyor(ImmutableRoaringBitmap x2)
public void or(ImmutableRoaringBitmap x2)
x2
- other bitmappublic void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
readExternal
in interface Externalizable
IOException
ClassNotFoundException
public void remove(int x)
remove
in interface BitmapDataProvider
x
- integer value representing the index in a bitmappublic void remove(long rangeStart, long rangeEnd)
rangeStart
- inclusive beginning of rangerangeEnd
- exclusive ending of range@Deprecated public void remove(int rangeStart, int rangeEnd)
rangeStart
- inclusive beginning of rangerangeEnd
- exclusive ending of rangepublic boolean removeRunCompression()
protected void repairAfterLazy()
public boolean runOptimize()
public ImmutableRoaringBitmap toImmutableRoaringBitmap()
(ImmutableRoaringBitmap) bitmap
public void trim()
trim
in interface BitmapDataProvider
public void writeExternal(ObjectOutput out) throws IOException
writeExternal
in interface Externalizable
IOException
public void xor(ImmutableRoaringBitmap x2)
x2
- other bitmappublic static long maximumSerializedSize(int cardinality, int universe_size)
cardinality
- maximal cardinalityuniverse_size
- maximal valueCopyright © 2016. All Rights Reserved.