public final class BitmapContainer extends Container implements Cloneable
Modifier and Type | Field and Description |
---|---|
protected static int |
MAX_CAPACITY |
static boolean |
USE_BRANCHLESS
optimization flag: whether the cardinality of the bitmaps is maintained through branchless
operations
|
ContainerNames
Constructor and Description |
---|
BitmapContainer()
Create a bitmap container with all bits set to false
|
BitmapContainer(int firstOfRun,
int lastOfRun)
Create a bitmap container with a run of ones from firstOfRun to lastOfRun.
|
BitmapContainer(long[] newBitmap,
int newCardinality)
Create a new container, no copy is made.
|
BitmapContainer(MappeableBitmapContainer bc)
Creates a new non-mappeable container from a mappeable one.
|
Modifier and Type | Method and Description |
---|---|
Container |
add(int begin,
int end)
Return a new container with all shorts in [begin,end) added using an unsigned interpretation.
|
Container |
add(short i)
Add a short to the container.
|
ArrayContainer |
and(ArrayContainer value2)
Computes the bitwise AND of this container with another (intersection).
|
Container |
and(BitmapContainer value2)
Computes the bitwise AND of this container with another (intersection).
|
Container |
and(RunContainer x)
Computes the bitwise AND of this container with another (intersection).
|
int |
andCardinality(ArrayContainer value2) |
int |
andCardinality(BitmapContainer value2) |
int |
andCardinality(RunContainer x) |
Container |
andNot(ArrayContainer value2)
Computes the bitwise ANDNOT of this container with another (difference).
|
Container |
andNot(BitmapContainer value2)
Computes the bitwise ANDNOT of this container with another (difference).
|
Container |
andNot(RunContainer x)
Computes the bitwise ANDNOT of this container with another (difference).
|
protected long |
bitValue(short i) |
protected int |
cardinalityInRange(int start,
int end) |
void |
clear()
Empties the container
|
BitmapContainer |
clone() |
protected void |
computeCardinality()
Recomputes the cardinality of the bitmap.
|
protected boolean |
contains(ArrayContainer arrayContainer) |
protected boolean |
contains(BitmapContainer bitmapContainer) |
protected boolean |
contains(RunContainer runContainer) |
boolean |
contains(short i)
Checks whether the contain contains the provided value
|
void |
deserialize(DataInput in)
Deserialize (recover) the container.
|
boolean |
equals(Object o) |
protected void |
fillArray(short[] array)
Fill the array with set bits
|
void |
fillLeastSignificant16bits(int[] x,
int i,
int mask)
Fill the least significant 16 bits of the integer array, starting at index i, with the short
values from this container.
|
int |
first()
Get the first integer held in the container
|
Container |
flip(short i)
Add a short to the container if it is not present, otherwise remove it.
|
void |
forEach(short msb,
IntConsumer ic)
Iterate through the values of this container and pass them
along to the IntConsumer, using msb as the 16 most significant bits.
|
protected int |
getArraySizeInBytes()
Size of the underlying array
|
int |
getCardinality()
Computes the distinct number of short values in the container.
|
ShortIterator |
getReverseShortIterator()
Iterator to visit the short values in the container in descending order.
|
static ShortIterator |
getReverseShortIterator(long[] bitmap)
Return a bitmap iterator over this array
|
PeekableShortIterator |
getShortIterator()
Iterator to visit the short values in the container in ascending order.
|
static PeekableShortIterator |
getShortIterator(long[] bitmap)
Return a bitmap iterator over this array
|
int |
getSizeInBytes()
Computes an estimate of the memory usage of this container.
|
int |
hashCode() |
Container |
iadd(int begin,
int end)
Add all shorts in [begin,end) using an unsigned interpretation.
|
Container |
iand(ArrayContainer b2)
Computes the in-place bitwise AND of this container with another (intersection).
|
Container |
iand(BitmapContainer b2)
Computes the in-place bitwise AND of this container with another (intersection).
|
Container |
iand(RunContainer x)
Computes the in-place bitwise AND of this container with another (intersection).
|
Container |
iandNot(ArrayContainer b2)
Computes the in-place bitwise ANDNOT of this container with another (difference).
|
Container |
iandNot(BitmapContainer b2)
Computes the in-place bitwise ANDNOT of this container with another (difference).
|
Container |
iandNot(RunContainer x)
Computes the in-place bitwise ANDNOT of this container with another (difference).
|
protected Container |
ilazyor(ArrayContainer value2) |
protected Container |
ilazyor(BitmapContainer x) |
protected Container |
ilazyor(RunContainer x) |
Container |
inot(int firstOfRange,
int lastOfRange)
Computes the in-place bitwise NOT of this container (complement).
|
boolean |
intersects(ArrayContainer value2)
Returns true if the current container intersects the other container.
|
boolean |
intersects(BitmapContainer value2)
Returns true if the current container intersects the other container.
|
boolean |
intersects(RunContainer x)
Returns true if the current container intersects the other container.
|
BitmapContainer |
ior(ArrayContainer value2)
Computes the in-place bitwise OR of this container with another (union).
|
Container |
ior(BitmapContainer b2)
Computes the in-place bitwise OR of this container with another (union).
|
Container |
ior(RunContainer x)
Computes the in-place bitwise OR of this container with another (union).
|
Container |
iremove(int begin,
int end)
Remove shorts in [begin,end) using an unsigned interpretation.
|
protected boolean |
isFull() |
Iterator<Short> |
iterator() |
Container |
ixor(ArrayContainer value2)
Computes the in-place bitwise XOR of this container with another (symmetric difference).
|
Container |
ixor(BitmapContainer b2)
Computes the in-place bitwise XOR of this container with another (symmetric difference).
|
Container |
ixor(RunContainer x)
Computes the in-place bitwise XOR of this container with another (symmetric difference).
|
int |
last()
Get the last integer held in the container
|
protected Container |
lazyor(ArrayContainer value2) |
protected Container |
lazyor(BitmapContainer x) |
protected Container |
lazyor(RunContainer x) |
Container |
limit(int maxcardinality)
Create a new Container containing at most maxcardinality integers.
|
protected void |
loadData(ArrayContainer arrayContainer) |
int |
nextSetBit(int i)
Find the index of the next set bit greater or equal to i, returns -1 if none found.
|
short |
nextUnsetBit(int i)
Find the index of the next unset bit greater or equal to i, returns -1 if none found.
|
Container |
not(int firstOfRange,
int lastOfRange)
Computes the bitwise NOT of this container (complement).
|
int |
numberOfRunsAdjustment()
Computes the number of runs
|
int |
numberOfRunsLowerBound(int mustNotExceed)
Counts how many runs there is in the bitmap, up to a maximum
|
Container |
or(ArrayContainer value2)
Computes the bitwise OR of this container with another (union).
|
Container |
or(BitmapContainer value2)
Computes the bitwise OR of this container with another (union).
|
Container |
or(RunContainer x)
Computes the bitwise OR of this container with another (union).
|
int |
prevSetBit(int i)
Find the index of the previous set bit less than or equal to i, returns -1 if none found.
|
int |
rank(short lowbits)
Rank returns the number of integers that are smaller or equal to x (Rank(infinity) would be
GetCardinality()).
|
void |
readExternal(ObjectInput in) |
Container |
remove(int begin,
int end)
Return a new container with all shorts in [begin,end) remove using an unsigned interpretation.
|
Container |
remove(short i)
Remove the short from this container.
|
Container |
repairAfterLazy()
The output of a lazyOR or lazyIOR might be an invalid container, this should be called on it.
|
Container |
runOptimize()
Convert to RunContainers, when the result is smaller.
|
short |
select(int j)
Return the jth value
|
void |
serialize(DataOutput out)
Serialize the container.
|
int |
serializedSizeInBytes()
Report the number of bytes required to serialize this container.
|
protected static int |
serializedSizeInBytes(int unusedCardinality) |
ArrayContainer |
toArrayContainer()
Copies the data to an array container
|
BitmapContainer |
toBitmapContainer()
Convert the current container to a BitmapContainer, if a conversion is needed.
|
LongBuffer |
toLongBuffer()
Return the content of this container as a LongBuffer.
|
MappeableContainer |
toMappeableContainer()
Convert to a mappeable container.
|
String |
toString() |
void |
trim()
If possible, recover wasted memory.
|
protected void |
updateCardinality(int prevOnes,
int newOnes) |
protected void |
writeArray(DataOutput out)
Write just the underlying array.
|
void |
writeExternal(ObjectOutput out) |
Container |
xor(ArrayContainer value2)
Computes the bitwise XOR of this container with another (symmetric difference).
|
Container |
xor(BitmapContainer value2)
Computes the bitwise XOR of this container with another (symmetric difference).
|
Container |
xor(RunContainer x)
Computes the bitwise XOR of this container with another (symmetric difference).
|
and, andCardinality, andNot, assertNonEmpty, contains, getContainerName, iand, iandNot, intersects, ior, ixor, lazyIOR, lazyOR, or, rangeOfOnes, xor, xorCardinality
finalize, getClass, notify, notifyAll, wait, wait, wait
forEach, spliterator
protected static final int MAX_CAPACITY
public static final boolean USE_BRANCHLESS
public BitmapContainer()
public BitmapContainer(int firstOfRun, int lastOfRun)
firstOfRun
- first indexlastOfRun
- last index (range is exclusive)public BitmapContainer(long[] newBitmap, int newCardinality)
newBitmap
- contentnewCardinality
- desired cardinality.public BitmapContainer(MappeableBitmapContainer bc)
bc
- the original containerpublic static ShortIterator getReverseShortIterator(long[] bitmap)
bitmap
- array to be iterated overpublic static PeekableShortIterator getShortIterator(long[] bitmap)
bitmap
- array to be iterated overprotected static int serializedSizeInBytes(int unusedCardinality)
public Container add(int begin, int end)
Container
public Container add(short i)
Container
public ArrayContainer and(ArrayContainer value2)
Container
public Container and(BitmapContainer value2)
Container
public Container and(RunContainer x)
Container
public int andCardinality(ArrayContainer value2)
andCardinality
in class Container
public int andCardinality(BitmapContainer value2)
andCardinality
in class Container
public int andCardinality(RunContainer x)
andCardinality
in class Container
public Container andNot(ArrayContainer value2)
Container
public Container andNot(BitmapContainer value2)
Container
public Container andNot(RunContainer x)
Container
public void clear()
Container
public BitmapContainer clone()
protected void computeCardinality()
protected int cardinalityInRange(int start, int end)
protected void updateCardinality(int prevOnes, int newOnes)
public boolean contains(short i)
Container
protected boolean contains(BitmapContainer bitmapContainer)
protected boolean contains(RunContainer runContainer)
protected boolean contains(ArrayContainer arrayContainer)
protected long bitValue(short i)
public void deserialize(DataInput in) throws IOException
Container
deserialize
in class Container
in
- the DataInput streamIOException
- Signals that an I/O exception has occurred.protected void fillArray(short[] array)
array
- container (should be sufficiently large)public void fillLeastSignificant16bits(int[] x, int i, int mask)
Container
fillLeastSignificant16bits
in class Container
x
- provided arrayi
- starting indexmask
- indicates most significant bitspublic Container flip(short i)
Container
protected int getArraySizeInBytes()
Container
getArraySizeInBytes
in class Container
public int getCardinality()
Container
getCardinality
in class Container
public ShortIterator getReverseShortIterator()
Container
getReverseShortIterator
in class Container
public PeekableShortIterator getShortIterator()
Container
getShortIterator
in class Container
public int getSizeInBytes()
Container
getSizeInBytes
in class Container
public Container iadd(int begin, int end)
Container
public Container iand(ArrayContainer b2)
Container
public Container iand(BitmapContainer b2)
Container
public Container iand(RunContainer x)
Container
public Container iandNot(ArrayContainer b2)
Container
public Container iandNot(BitmapContainer b2)
Container
public Container iandNot(RunContainer x)
Container
protected Container ilazyor(ArrayContainer value2)
protected Container ilazyor(BitmapContainer x)
protected Container ilazyor(RunContainer x)
public Container inot(int firstOfRange, int lastOfRange)
Container
public boolean intersects(ArrayContainer value2)
Container
intersects
in class Container
value2
- other containerpublic boolean intersects(BitmapContainer value2)
Container
intersects
in class Container
value2
- other containerpublic boolean intersects(RunContainer x)
Container
intersects
in class Container
x
- other containerpublic BitmapContainer ior(ArrayContainer value2)
Container
public Container ior(BitmapContainer b2)
Container
public Container ior(RunContainer x)
Container
public Container iremove(int begin, int end)
Container
public Container ixor(ArrayContainer value2)
Container
public Container ixor(BitmapContainer b2)
Container
public Container ixor(RunContainer x)
Container
protected Container lazyor(ArrayContainer value2)
protected Container lazyor(BitmapContainer x)
protected Container lazyor(RunContainer x)
public Container limit(int maxcardinality)
Container
protected void loadData(ArrayContainer arrayContainer)
public int nextSetBit(int i)
i
- starting indexpublic short nextUnsetBit(int i)
i
- starting indexpublic Container not(int firstOfRange, int lastOfRange)
Container
public int numberOfRunsAdjustment()
public int numberOfRunsLowerBound(int mustNotExceed)
mustNotExceed
- maximum of runs beyond which counting is pointlesspublic Container or(ArrayContainer value2)
Container
protected boolean isFull()
public Container or(BitmapContainer value2)
Container
public Container or(RunContainer x)
Container
public int prevSetBit(int i)
i
- starting indexpublic int rank(short lowbits)
Container
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
readExternal
in interface Externalizable
IOException
ClassNotFoundException
public Container remove(int begin, int end)
Container
public Container remove(short i)
Container
public Container repairAfterLazy()
Container
repairAfterLazy
in class Container
public Container runOptimize()
Container
runOptimize
in class Container
public short select(int j)
Container
public void serialize(DataOutput out) throws IOException
Container
serialize
in class Container
out
- the DataOutput streamIOException
- Signals that an I/O exception has occurred.public int serializedSizeInBytes()
Container
serializedSizeInBytes
in class Container
public ArrayContainer toArrayContainer()
public LongBuffer toLongBuffer()
public MappeableContainer toMappeableContainer()
Container
toMappeableContainer
in class Container
public void trim()
Container
protected void writeArray(DataOutput out) throws IOException
Container
writeArray
in class Container
out
- output streamIOException
- in case of failurepublic void writeExternal(ObjectOutput out) throws IOException
writeExternal
in interface Externalizable
IOException
public Container xor(ArrayContainer value2)
Container
public Container xor(BitmapContainer value2)
Container
public Container xor(RunContainer x)
Container
public void forEach(short msb, IntConsumer ic)
Container
public BitmapContainer toBitmapContainer()
Container
toBitmapContainer
in class Container
public int first()
Container
Copyright © 2018. All rights reserved.