Package com.googlecode.javaewah32
Class IteratingBufferedRunningLengthWord32
- java.lang.Object
-
- com.googlecode.javaewah32.IteratingBufferedRunningLengthWord32
-
- All Implemented Interfaces:
IteratingRLW32,Cloneable
public final class IteratingBufferedRunningLengthWord32 extends Object implements IteratingRLW32, Cloneable
Mostly for internal use. Similar to BufferedRunningLengthWord32, but automatically advances to the next BufferedRunningLengthWord32 as words are discarded.- Since:
- 0.5.0
- Author:
- Daniel Lemire and David McIntosh
-
-
Constructor Summary
Constructors Constructor Description IteratingBufferedRunningLengthWord32(EWAHCompressedBitmap32 bitmap)Instantiates a new iterating buffered running length word.IteratingBufferedRunningLengthWord32(EWAHIterator32 iterator)Instantiates a new iterating buffered running length word.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description IteratingBufferedRunningLengthWord32clone()voiddiscardFirstWords(int x)Discard first words, iterating to the next running length word if needed.voiddiscardLiteralWords(int x)Discard x literal words (assumes that there is no running word)voiddiscardRunningWords()Discard all running wordsvoiddischarge(BitmapStorage32 container)Write out the remaining wordsintdischarge(BitmapStorage32 container, int max)Write out up to max words, returns how many were writtenprotected static voiddischarge(BufferedRunningLengthWord32 initialWord, EWAHIterator32 iterator, BitmapStorage32 container)For internal use.voiddischargeAsEmpty(BitmapStorage32 container)Write out the remain words, transforming them to zeroes.intdischargeNegated(BitmapStorage32 container, int max)Write out up to max words (negated), returns how many were writtenintgetLiteralWordAt(int index)Get the nth literal word for the current running length wordintgetNumberOfLiteralWords()Gets the number of literal words for the current running length word.booleangetRunningBit()Gets the running bit.intgetRunningLength()Gets the running length.booleannext()Move to the next RunningLengthWordintsize()Size in uncompressed words of the current running length word.voidwriteLiteralWords(int numWords, BitmapStorage32 container)write the first N literal words to the target bitmap.voidwriteNegatedLiteralWords(int numWords, BitmapStorage32 container)write the first N literal words (negated) to the target bitmap.
-
-
-
Constructor Detail
-
IteratingBufferedRunningLengthWord32
public IteratingBufferedRunningLengthWord32(EWAHIterator32 iterator)
Instantiates a new iterating buffered running length word.- Parameters:
iterator- iterator
-
IteratingBufferedRunningLengthWord32
public IteratingBufferedRunningLengthWord32(EWAHCompressedBitmap32 bitmap)
Instantiates a new iterating buffered running length word.- Parameters:
bitmap- over which we want to iterate
-
-
Method Detail
-
discardFirstWords
public void discardFirstWords(int x)
Discard first words, iterating to the next running length word if needed.- Specified by:
discardFirstWordsin interfaceIteratingRLW32- Parameters:
x- the x
-
discardLiteralWords
public void discardLiteralWords(int x)
Description copied from interface:IteratingRLW32Discard x literal words (assumes that there is no running word)- Specified by:
discardLiteralWordsin interfaceIteratingRLW32- Parameters:
x- the number of words to discard
-
discardRunningWords
public void discardRunningWords()
Description copied from interface:IteratingRLW32Discard all running words- Specified by:
discardRunningWordsin interfaceIteratingRLW32
-
discharge
public int discharge(BitmapStorage32 container, int max)
Write out up to max words, returns how many were written- Parameters:
container- target for writesmax- maximal number of writes- Returns:
- how many written
-
dischargeNegated
public int dischargeNegated(BitmapStorage32 container, int max)
Write out up to max words (negated), returns how many were written- Parameters:
container- target for writesmax- maximal number of writes- Returns:
- how many written
-
next
public boolean next()
Move to the next RunningLengthWord- Specified by:
nextin interfaceIteratingRLW32- Returns:
- whether the move was possible
-
dischargeAsEmpty
public void dischargeAsEmpty(BitmapStorage32 container)
Write out the remain words, transforming them to zeroes.- Parameters:
container- target for writes
-
discharge
public void discharge(BitmapStorage32 container)
Write out the remaining words- Parameters:
container- target for writes
-
getLiteralWordAt
public int getLiteralWordAt(int index)
Get the nth literal word for the current running length word- Specified by:
getLiteralWordAtin interfaceIteratingRLW32- Parameters:
index- zero based index- Returns:
- the literal word
-
getNumberOfLiteralWords
public int getNumberOfLiteralWords()
Gets the number of literal words for the current running length word.- Specified by:
getNumberOfLiteralWordsin interfaceIteratingRLW32- Returns:
- the number of literal words
-
getRunningBit
public boolean getRunningBit()
Gets the running bit.- Specified by:
getRunningBitin interfaceIteratingRLW32- Returns:
- the running bit
-
getRunningLength
public int getRunningLength()
Gets the running length.- Specified by:
getRunningLengthin interfaceIteratingRLW32- Returns:
- the running length
-
size
public int size()
Size in uncompressed words of the current running length word.- Specified by:
sizein interfaceIteratingRLW32- Returns:
- the int
-
writeLiteralWords
public void writeLiteralWords(int numWords, BitmapStorage32 container)write the first N literal words to the target bitmap. Does not discard the words or perform iteration.- Parameters:
numWords- number of words to be writtencontainer- where we write the data
-
writeNegatedLiteralWords
public void writeNegatedLiteralWords(int numWords, BitmapStorage32 container)write the first N literal words (negated) to the target bitmap. Does not discard the words or perform iteration.- Parameters:
numWords- number of words to be writtencontainer- where we write the data
-
discharge
protected static void discharge(BufferedRunningLengthWord32 initialWord, EWAHIterator32 iterator, BitmapStorage32 container)
For internal use. (One could use the non-static discharge method instead, but we expect them to be slower.)- Parameters:
initialWord- the initial worditerator- the iteratorcontainer- the container
-
clone
public IteratingBufferedRunningLengthWord32 clone() throws CloneNotSupportedException
- Specified by:
clonein interfaceIteratingRLW32- Overrides:
clonein classObject- Returns:
- a copy of the iterator
- Throws:
CloneNotSupportedException- this should not be thrown in theory
-
-