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
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate BufferedRunningLengthWord
private final Buffer
private EWAHIterator
private int
-
Constructor Summary
ConstructorsConstructorDescriptionInstantiates a new iterating buffered running length word.Instantiates a new iterating buffered running length word. -
Method Summary
Modifier and TypeMethodDescriptionclone()
void
discardFirstWords
(long x) Discard first words, iterating to the next running length word if needed.void
Discard all running wordsvoid
discharge
(BitmapStorage container) Write out the remaining wordslong
discharge
(BitmapStorage container, long max) Write out up to max words, returns how many were writtenprivate static void
discharge
(BufferedRunningLengthWord initialWord, EWAHIterator iterator, BitmapStorage container) For internal use.void
dischargeAsEmpty
(BitmapStorage container) Write out the remain words, transforming them to zeroes.long
dischargeNegated
(BitmapStorage container, long max) Write out up to max words (negated), returns how many were writtenlong
getLiteralWordAt
(int index) Get the nth literal word for the current running length wordint
Gets the number of literal words for the current running length word.boolean
Gets the running bit.long
Gets the running length.boolean
next()
Move to the next RunningLengthWordlong
size()
Size in uncompressed words of the current running length word.void
writeLiteralWords
(int numWords, BitmapStorage container) write the first N literal words to the target bitmap.void
writeNegatedLiteralWords
(int numWords, BitmapStorage container) write the first N literal words (negated) to the target bitmap.
-
Field Details
-
brlw
-
buffer
-
literalWordStartPosition
private int literalWordStartPosition -
iterator
-
-
Constructor Details
-
IteratingBufferedRunningLengthWord
Instantiates a new iterating buffered running length word.- Parameters:
iterator
- iterator
-
IteratingBufferedRunningLengthWord
Instantiates a new iterating buffered running length word.- Parameters:
bitmap
- over which we want to iterate
-
-
Method Details
-
discardFirstWords
public void discardFirstWords(long x) Discard first words, iterating to the next running length word if needed.- Specified by:
discardFirstWords
in interfaceIteratingRLW
- Parameters:
x
- the number of words to be discarded
-
discardRunningWords
public void discardRunningWords()Description copied from interface:IteratingRLW
Discard all running words- Specified by:
discardRunningWords
in interfaceIteratingRLW
-
next
public boolean next()Move to the next RunningLengthWord- Specified by:
next
in interfaceIteratingRLW
- Returns:
- whether the move was possible
-
discharge
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
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
Write out the remain words, transforming them to zeroes.- Parameters:
container
- target for writes
-
discharge
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:
getLiteralWordAt
in 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:
getNumberOfLiteralWords
in interfaceIteratingRLW
- Returns:
- the number of literal words
-
getRunningBit
public boolean getRunningBit()Gets the running bit.- Specified by:
getRunningBit
in interfaceIteratingRLW
- Returns:
- the running bit
-
getRunningLength
public long getRunningLength()Gets the running length.- Specified by:
getRunningLength
in interfaceIteratingRLW
- Returns:
- the running length
-
size
public long size()Size in uncompressed words of the current running length word.- Specified by:
size
in interfaceIteratingRLW
- Returns:
- the long
-
writeLiteralWords
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
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
-
discharge
private static void discharge(BufferedRunningLengthWord initialWord, EWAHIterator iterator, BitmapStorage 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
- Specified by:
clone
in interfaceIteratingRLW
- Overrides:
clone
in classObject
- Returns:
- a copy of the iterator
- Throws:
CloneNotSupportedException
- this should not be thrown in theory
-