public class RoaringBitmap extends Object implements Cloneable, Serializable, Iterable<Integer>, Externalizable, ImmutableBitmapDataProvider
import org.roaringbitmap.*;
//...
RoaringBitmap rr = RoaringBitmap.bitmapOf(1,2,3,1000);
RoaringBitmap rr2 = new RoaringBitmap();
for(int k = 4000; k<4255;++k) rr2.add(k);
RoaringBitmap rror = RoaringBitmap.or(rr, rr2);
Constructor and Description |
---|
RoaringBitmap()
Create an empty bitmap
|
Modifier and Type | Method and Description |
---|---|
void |
add(int x)
set the value to "true", whether it already appears or not.
|
void |
and(RoaringBitmap x2)
In-place bitwise AND (intersection) operation.
|
static RoaringBitmap |
and(RoaringBitmap x1,
RoaringBitmap x2)
Bitwise AND (intersection) operation.
|
void |
andNot(RoaringBitmap x2)
In-place bitwise ANDNOT (difference) operation.
|
static RoaringBitmap |
andNot(RoaringBitmap x1,
RoaringBitmap x2)
Bitwise ANDNOT (difference) operation.
|
static RoaringBitmap |
bitmapOf(int... dat)
Generate a bitmap with the specified values set to true.
|
void |
clear()
reset to an empty bitmap; result occupies as much space a newly
created bitmap.
|
RoaringBitmap |
clone() |
boolean |
contains(int x)
Checks whether the value in included, which is equivalent to checking
if the corresponding bit is set (get in BitSet class).
|
void |
deserialize(DataInput in)
Deserialize (retrieve) this bitmap.
|
boolean |
equals(Object o) |
void |
flip(int rangeStart,
int rangeEnd)
Modifies the current bitmap by complementing the bits in the given
range, from rangeStart (inclusive) rangeEnd (exclusive).
|
static RoaringBitmap |
flip(RoaringBitmap bm,
int rangeStart,
int rangeEnd)
Complements the bits in the given range, from rangeStart (inclusive)
rangeEnd (exclusive).
|
int |
getCardinality()
Returns the number of distinct integers added to the bitmap (e.g.,
number of bits set).
|
IntIterator |
getIntIterator() |
IntIterator |
getReverseIntIterator() |
int |
getSizeInBytes()
Estimate of the memory usage of this data structure.
|
int |
hashCode() |
boolean |
isEmpty()
Checks whether the bitmap is empty.
|
Iterator<Integer> |
iterator()
iterate over the positions of the true values.
|
RoaringBitmap |
limit(int maxcardinality)
Create a new Roaring bitmap containing at most maxcardinality integers.
|
void |
or(RoaringBitmap x2)
In-place bitwise OR (union) operation.
|
static RoaringBitmap |
or(RoaringBitmap x1,
RoaringBitmap x2)
Bitwise OR (union) operation.
|
int |
rank(int x)
Rank returns the number of integers that are smaller or equal to x (Rank(infinity) would be GetCardinality()).
|
void |
readExternal(ObjectInput in) |
void |
remove(int x)
If present remove the specified integers (effectively, sets its bit
value to false)
|
int |
select(int j)
Return the jth value stored in this bitmap.
|
void |
serialize(DataOutput out)
Serialize this bitmap.
|
int |
serializedSizeInBytes()
Report the number of bytes required to serialize this bitmap.
|
int[] |
toArray()
Return the set values as an array.
|
String |
toString()
A string describing the bitmap.
|
void |
trim()
Recover allocated but unused memory.
|
void |
writeExternal(ObjectOutput out) |
void |
xor(RoaringBitmap x2)
In-place bitwise XOR (symmetric difference) operation.
|
static RoaringBitmap |
xor(RoaringBitmap x1,
RoaringBitmap x2)
Bitwise XOR (symmetric difference) operation.
|
finalize, getClass, notify, notifyAll, wait, wait, wait
forEach, spliterator
public static RoaringBitmap and(RoaringBitmap x1, RoaringBitmap x2)
x1
- first bitmapx2
- other bitmapFastAggregation.and(RoaringBitmap...)
public static RoaringBitmap andNot(RoaringBitmap x1, RoaringBitmap x2)
x1
- first bitmapx2
- other bitmappublic static RoaringBitmap bitmapOf(int... dat)
dat
- set valuespublic static RoaringBitmap flip(RoaringBitmap bm, int rangeStart, int rangeEnd)
bm
- bitmap being negatedrangeStart
- inclusive beginning of rangerangeEnd
- exclusive ending of rangepublic static RoaringBitmap or(RoaringBitmap x1, RoaringBitmap x2)
x1
- first bitmapx2
- other bitmapFastAggregation.or(RoaringBitmap...)
,
FastAggregation.horizontal_or(RoaringBitmap...)
public int rank(int x)
rank
in interface ImmutableBitmapDataProvider
x
- upper limitpublic int select(int j)
select
in interface ImmutableBitmapDataProvider
j
- index of the valuepublic static RoaringBitmap xor(RoaringBitmap x1, RoaringBitmap x2)
x1
- first bitmapx2
- other bitmapFastAggregation.xor(RoaringBitmap...)
,
FastAggregation.horizontal_xor(RoaringBitmap...)
public void add(int x)
x
- integer valuepublic void and(RoaringBitmap x2)
x2
- other bitmappublic void andNot(RoaringBitmap x2)
x2
- other bitmappublic void clear()
public RoaringBitmap clone()
public boolean contains(int x)
contains
in interface ImmutableBitmapDataProvider
x
- integer valuepublic void deserialize(DataInput in) throws IOException
in
- the DataInput streamIOException
- Signals that an I/O exception has occurred.public void flip(int rangeStart, int rangeEnd)
rangeStart
- inclusive beginning of rangerangeEnd
- exclusive ending of rangepublic int getCardinality()
getCardinality
in interface ImmutableBitmapDataProvider
public IntIterator getIntIterator()
getIntIterator
in interface ImmutableBitmapDataProvider
public IntIterator getReverseIntIterator()
getReverseIntIterator
in interface ImmutableBitmapDataProvider
public int getSizeInBytes()
getSizeInBytes
in interface ImmutableBitmapDataProvider
public boolean isEmpty()
isEmpty
in interface ImmutableBitmapDataProvider
public void or(RoaringBitmap x2)
x2
- other bitmappublic void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
readExternal
in interface Externalizable
IOException
ClassNotFoundException
public void remove(int x)
x
- integer value representing the index in a bitmappublic void serialize(DataOutput out) throws IOException
serialize
in interface ImmutableBitmapDataProvider
out
- the DataOutput streamIOException
- Signals that an I/O exception has occurred.public int serializedSizeInBytes()
serializedSizeInBytes
in interface ImmutableBitmapDataProvider
public RoaringBitmap limit(int maxcardinality)
limit
in interface ImmutableBitmapDataProvider
maxcardinality
- maximal cardinalitypublic int[] toArray()
toArray
in interface ImmutableBitmapDataProvider
public String toString()
public void trim()
public void writeExternal(ObjectOutput out) throws IOException
writeExternal
in interface Externalizable
IOException
public void xor(RoaringBitmap x2)
x2
- other bitmapCopyright © 2015. All Rights Reserved.