Package com.googlecode.javaewah32
Class BitCounter32
java.lang.Object
com.googlecode.javaewah32.BitCounter32
- All Implemented Interfaces:
BitmapStorage32
BitCounter is a fake bitset data structure. Instead of storing the actual
data, it only records the number of set bits.
- Since:
- 0.5.0
- Author:
- Daniel Lemire and David McIntosh
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
addLiteralWord(int newData)
Virtually add literal words directly to the bitmapvoid
addStreamOfEmptyWords(boolean v, int number)
virtually add many zeroes or ones.void
addStreamOfLiteralWords(com.googlecode.javaewah32.Buffer32 buffer, int start, int number)
virtually add several literal words.void
addStreamOfNegatedLiteralWords(com.googlecode.javaewah32.Buffer32 buffer, int start, int number)
virtually add several negated literal words.void
addWord(int newData)
Virtually add words directly to the bitmapvoid
clear()
Empties the container.int
getCount()
As you act on this class, it records the number of set (true) bits.void
setSizeInBitsWithinLastWord(int bits)
Sets the size in bits of the bitmap as an *uncompressed* bitmap.
-
Constructor Details
-
BitCounter32
public BitCounter32()
-
-
Method Details
-
addWord
public void addWord(int newData)Virtually add words directly to the bitmap- Specified by:
addWord
in interfaceBitmapStorage32
- Parameters:
newData
- the word
-
addLiteralWord
public void addLiteralWord(int newData)Virtually add literal words directly to the bitmap- Specified by:
addLiteralWord
in interfaceBitmapStorage32
- Parameters:
newData
- the word
-
addStreamOfLiteralWords
public void addStreamOfLiteralWords(com.googlecode.javaewah32.Buffer32 buffer, int start, int number)virtually add several literal words.- Specified by:
addStreamOfLiteralWords
in interfaceBitmapStorage32
- Parameters:
buffer
- the buffer wrapping the literal wordsstart
- the starting point in the arraynumber
- the number of literal words to add
-
addStreamOfEmptyWords
public void addStreamOfEmptyWords(boolean v, int number)virtually add many zeroes or ones.- Specified by:
addStreamOfEmptyWords
in interfaceBitmapStorage32
- Parameters:
v
- zeros or onesnumber
- how many to words add
-
addStreamOfNegatedLiteralWords
public void addStreamOfNegatedLiteralWords(com.googlecode.javaewah32.Buffer32 buffer, int start, int number)virtually add several negated literal words.- Specified by:
addStreamOfNegatedLiteralWords
in interfaceBitmapStorage32
- Parameters:
buffer
- the buffer wrapping the literal wordsstart
- the starting point in the arraynumber
- the number of literal words to add
-
clear
public void clear()Description copied from interface:BitmapStorage32
Empties the container.- Specified by:
clear
in interfaceBitmapStorage32
-
getCount
public int getCount()As you act on this class, it records the number of set (true) bits.- Returns:
- number of set bits
-
setSizeInBitsWithinLastWord
public void setSizeInBitsWithinLastWord(int bits)Description copied from interface:BitmapStorage32
Sets the size in bits of the bitmap as an *uncompressed* bitmap. Normally, this is used to reduce the size of the bitmaps within the scope of the last word. Specifically, this means that (sizeInBits()+31)/32 must be equal to (size+31)/32. If needed, the bitmap can be further padded with zeroes.- Specified by:
setSizeInBitsWithinLastWord
in interfaceBitmapStorage32
- Parameters:
bits
- the size in bits
-