Package com.qfs.bitmap
Interface IBitmap
- All Superinterfaces:
Cloneable,IClone<IBitmap>,Serializable
- All Known Subinterfaces:
IClearableBitmap
- All Known Implementing Classes:
Bitmap,ChunkedBitmap,QFSBitmap
A bitmap is a possibly large sequence of bits on which logical operations like AND, OR, XOR can
be efficiently applied.
- Author:
- ActiveViam
-
Method Summary
Modifier and TypeMethodDescriptionPerforms a logical AND operation between two bitmaps.voidPerforms a logical AND operation between two bitmaps.Performs a logical AND NOT operation between two bitmaps.voidPerforms a logical AND NOT operation between two bitmaps.intReports the number of bits set in the bitmap.voidclear()Clears the bitmap.longEstimates the size of the internal data only (without the structure costs).voidforEachBit(IMatchProcedure procedure) Executes a procedure for each of the bits that are set in the bitmap.booleanget(int i) Returns whether the bit at the given index is set or not.Returns an iterator.intgetLast()Gets the position of the last bit set in the bitmap.booleanisEmpty()Returns whether this bitmap is empty or not.voidnot(int sizeInBits) Reverses the bits in the bitmap, equivalent of the NOT logical operation.Performs a logical OR operation between two bitmaps.voidPerforms a logical OR operation between two bitmaps.voidset(int i) Sets the bit at position i totrue.longGets the total size of the index.default IntStreamstream()Returns a sequentialIntStreamwith this bitmap as its source.static StringReturns a human-readable representation of the givenbitmap.Performs a logical XOR operation between two bitmaps.voidPerforms a logical XOR operation between two bitmaps.
-
Method Details
-
set
void set(int i) Sets the bit at position i totrue.The bits must be set in increasing order.
- Parameters:
i- the index of the bit to set
-
get
boolean get(int i) Returns whether the bit at the given index is set or not.- Parameters:
i- the index of the bit- Returns:
trueif the bit is set,falseotherwise
-
getLast
int getLast()Gets the position of the last bit set in the bitmap.- Returns:
- the position of the last bit set, or
-1if no bit is set
-
clear
void clear()Clears the bitmap.After this call the bitmap will be empty.
-
cardinality
int cardinality()Reports the number of bits set in the bitmap.- Returns:
- this bitmap cardinality
-
and
Performs a logical AND operation between two bitmaps. It is responsibility of the user to clear the result before using this logic operation.- Parameters:
operand- the other bitmap operandresult- the bitmap where the result is appended
-
and
Performs a logical AND operation between two bitmaps.- Parameters:
other- other bitmap operand of the AND operator- Returns:
- AND result bitmap
-
or
Performs a logical OR operation between two bitmaps. It is responsibility of the user to clear the result before using this logic operation.- Parameters:
operand- the other bitmap operandresult- the bitmap where the result is appended
-
or
Performs a logical OR operation between two bitmaps.- Parameters:
other- other bitmap operand of the OR operator- Returns:
- OR result bitmap
-
xor
Performs a logical XOR operation between two bitmaps. It is responsibility of the user to clear the result before using this logic operation.- Parameters:
operand- the other bitmap operandresult- the bitmap where the result is appended
-
xor
Performs a logical XOR operation between two bitmaps.- Parameters:
other- other bitmap operand of the XOR operator- Returns:
- OR result bitmap
-
andNot
Performs a logical AND NOT operation between two bitmaps. It is responsibility of the user to clear the result before using this logic operation.- Parameters:
operand- the other bitmap operandresult- the bitmap where the result is appended
-
andNot
Performs a logical AND NOT operation between two bitmaps.- Parameters:
other- other bitmap operand of the AND NOT operator- Returns:
- OR result bitmap
-
not
void not(int sizeInBits) Reverses the bits in the bitmap, equivalent of the NOT logical operation.- Parameters:
sizeInBits- the size of the result, if the bitmap has a smaller size, ones will be appended, if the bitmap has a larger size, its size will be reduced
-
forEachBit
Executes a procedure for each of the bits that are set in the bitmap.- Parameters:
procedure- procedure to apply to each value in this bitmap
-
sizeInBytes
long sizeInBytes()Gets the total size of the index.This includes data as well as abject internal attributes, class pointers, ...
- Returns:
- estimated size of the bitmap, measured in bytes
-
dataSizeInBytes
long dataSizeInBytes()Estimates the size of the internal data only (without the structure costs).- Returns:
- size in bytes
-
isEmpty
boolean isEmpty()Returns whether this bitmap is empty or not.A bitmap is empty iff its
cardinalityis equal to0.- Returns:
trueif this bitmap is empty,falseotherwise
-
getIterator
IBitmapIterator getIterator()Returns an iterator.- Returns:
- an iterator
-
toString
Returns a human-readable representation of the givenbitmap.- Parameters:
bitmap- the bitmap to print- Returns:
- a human-readable representation of the bitmap
-
stream
Returns a sequentialIntStreamwith this bitmap as its source.- Returns:
- a sequential
IntStreamwith this bitmap as its source.
-