Package com.googlecode.javaewah
Class IteratingBufferedRunningLengthWord
- java.lang.Object
-
- com.googlecode.javaewah.IteratingBufferedRunningLengthWord
-
- All Implemented Interfaces:
IteratingRLW,Cloneable
public final class IteratingBufferedRunningLengthWord extends Object implements IteratingRLW, Cloneable
Mostly for internal use. Similar to BufferedRunningLengthWord, but automatically advances to the next BufferedRunningLengthWord as words are discarded.- Since:
- 0.4.0
- Author:
- David McIntosh
-
-
Constructor Summary
Constructors Constructor Description IteratingBufferedRunningLengthWord(EWAHCompressedBitmap bitmap)Instantiates a new iterating buffered running length word.IteratingBufferedRunningLengthWord(EWAHIterator iterator)Instantiates a new iterating buffered running length word.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description IteratingBufferedRunningLengthWordclone()voiddiscardFirstWords(long x)Discard first words, iterating to the next running length word if needed.voiddiscardLiteralWords(long x)Discard x literal words (assumes that there is no running word)voiddiscardRunningWords()Discard all running wordsvoiddischarge(BitmapStorage container)Write out the remaining wordslongdischarge(BitmapStorage container, long max)Write out up to max words, returns how many were writtenvoiddischargeAsEmpty(BitmapStorage container)Write out the remain words, transforming them to zeroes.longdischargeNegated(BitmapStorage container, long max)Write out up to max words (negated), returns how many were writtenlonggetLiteralWordAt(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.longgetRunningLength()Gets the running length.booleannext()Move to the next RunningLengthWordlongsize()Size in uncompressed words of the current running length word.voidwriteLiteralWords(int numWords, BitmapStorage container)write the first N literal words to the target bitmap.voidwriteNegatedLiteralWords(int numWords, BitmapStorage container)write the first N literal words (negated) to the target bitmap.
-
-
-
Constructor Detail
-
IteratingBufferedRunningLengthWord
public IteratingBufferedRunningLengthWord(EWAHIterator iterator)
Instantiates a new iterating buffered running length word.- Parameters:
iterator- iterator
-
IteratingBufferedRunningLengthWord
public IteratingBufferedRunningLengthWord(EWAHCompressedBitmap bitmap)
Instantiates a new iterating buffered running length word.- Parameters:
bitmap- over which we want to iterate
-
-
Method Detail
-
discardFirstWords
public void discardFirstWords(long x)
Discard first words, iterating to the next running length word if needed.- Specified by:
discardFirstWordsin interfaceIteratingRLW- Parameters:
x- the number of words to be discarded
-
discardLiteralWords
public void discardLiteralWords(long x)
Description copied from interface:IteratingRLWDiscard x literal words (assumes that there is no running word)- Specified by:
discardLiteralWordsin interfaceIteratingRLW- Parameters:
x- the number of words to discard
-
discardRunningWords
public void discardRunningWords()
Description copied from interface:IteratingRLWDiscard all running words- Specified by:
discardRunningWordsin interfaceIteratingRLW
-
next
public boolean next()
Move to the next RunningLengthWord- Specified by:
nextin interfaceIteratingRLW- Returns:
- whether the move was possible
-
discharge
public long discharge(BitmapStorage container, long 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 long dischargeNegated(BitmapStorage container, long 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
-
dischargeAsEmpty
public void dischargeAsEmpty(BitmapStorage container)
Write out the remain words, transforming them to zeroes.- Parameters:
container- target for writes
-
discharge
public void discharge(BitmapStorage container)
Write out the remaining words- Parameters:
container- target for writes
-
getLiteralWordAt
public long getLiteralWordAt(int index)
Get the nth literal word for the current running length word- Specified by:
getLiteralWordAtin interfaceIteratingRLW- 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 interfaceIteratingRLW- Returns:
- the number of literal words
-
getRunningBit
public boolean getRunningBit()
Gets the running bit.- Specified by:
getRunningBitin interfaceIteratingRLW- Returns:
- the running bit
-
getRunningLength
public long getRunningLength()
Gets the running length.- Specified by:
getRunningLengthin interfaceIteratingRLW- Returns:
- the running length
-
size
public long size()
Size in uncompressed words of the current running length word.- Specified by:
sizein interfaceIteratingRLW- Returns:
- the long
-
writeLiteralWords
public void writeLiteralWords(int numWords, BitmapStorage 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
-
writeNegatedLiteralWords
public void writeNegatedLiteralWords(int numWords, BitmapStorage 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
-
clone
public IteratingBufferedRunningLengthWord clone() throws CloneNotSupportedException
- Specified by:
clonein interfaceIteratingRLW- Overrides:
clonein classObject- Returns:
- a copy of the iterator
- Throws:
CloneNotSupportedException- this should not be thrown in theory
-
-