Package com.qfs.bitmap
Interface IBitmap
-
- All Superinterfaces:
Cloneable,IClone<IBitmap>,Serializable
- All Known Subinterfaces:
IClearableBitmap
- All Known Implementing Classes:
Bitmap,ChunkedBitmap,QFSBitmap
public interface IBitmap extends Serializable, IClone<IBitmap>
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
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description IBitmapand(IBitmap other)Performs a logical AND operation between two bitmaps.voidand(IBitmap operand, IBitmap result)Performs a logical AND operation between two bitmaps.IBitmapandNot(IBitmap other)Performs a logical AND NOT operation between two bitmaps.voidandNot(IBitmap operand, IBitmap result)Performs a logical AND NOT operation between two bitmaps.intcardinality()Reports the number of bits set in the bitmap.voidclear()Clears the bitmap.longdataSizeInBytes()Estimates 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.IBitmapIteratorgetIterator()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.IBitmapor(IBitmap other)Performs a logical OR operation between two bitmaps.voidor(IBitmap operand, IBitmap result)Performs a logical OR operation between two bitmaps.voidset(int i)Sets the bit at position i totrue.longsizeInBytes()Gets the total size of the index.default IntStreamstream()Returns a sequentialIntStreamwith this bitmap as its source.static StringtoString(IBitmap bitmap)Returns a human-readable representation of the givenbitmap.IBitmapxor(IBitmap other)Performs a logical XOR operation between two bitmaps.voidxor(IBitmap operand, IBitmap result)Performs a logical XOR operation between two bitmaps.
-
-
-
Method Detail
-
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
void and(IBitmap operand, IBitmap result)
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
IBitmap and(IBitmap other)
Performs a logical AND operation between two bitmaps.- Parameters:
other- other bitmap operand of the AND operator- Returns:
- AND result bitmap
-
or
void or(IBitmap operand, IBitmap result)
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
IBitmap or(IBitmap other)
Performs a logical OR operation between two bitmaps.- Parameters:
other- other bitmap operand of the OR operator- Returns:
- OR result bitmap
-
xor
void xor(IBitmap operand, IBitmap result)
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
IBitmap xor(IBitmap other)
Performs a logical XOR operation between two bitmaps.- Parameters:
other- other bitmap operand of the XOR operator- Returns:
- OR result bitmap
-
andNot
void andNot(IBitmap operand, IBitmap result)
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
IBitmap andNot(IBitmap other)
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
void forEachBit(IMatchProcedure procedure)
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
static String toString(IBitmap bitmap)
Returns a human-readable representation of the givenbitmap.- Parameters:
bitmap- the bitmap to print- Returns:
- a human-readable representation of the bitmap
-
-