@Override public IteratingBufferedRunningLengthWord clone() throws CloneNotSupportedException { IteratingBufferedRunningLengthWord answer = (IteratingBufferedRunningLengthWord) super .clone(); answer.brlw = this.brlw.clone(); answer.iterator = this.iterator.clone(); return answer; }
@Override public String toString() { return "running bit = " + getRunningBit() + " running length = " + getRunningLength() + " number of lit. words " + getNumberOfLiteralWords(); }
/** * Reset the values of this running length word so that it has the same * values as the other running length word. * * @param rlw the other running length word */ public void reset(final RunningLengthWord rlw) { reset(rlw.buffer.getWord(rlw.position)); }
/** * For internal use. (One could use the non-static discharge method * instead, but we expect them to be slower.) * * @param initialWord the initial word * @param iterator the iterator * @param container the container */ private static void discharge(final BufferedRunningLengthWord initialWord, final EWAHIterator iterator, final BitmapStorage container) { BufferedRunningLengthWord runningLengthWord = initialWord; for (; ; ) { final long runningLength = runningLengthWord.getRunningLength(); container.addStreamOfEmptyWords(runningLengthWord.getRunningBit(), runningLength); container.addStreamOfLiteralWords(iterator.buffer(), iterator.literalWords() + runningLengthWord.literalWordOffset, runningLengthWord.getNumberOfLiteralWords() ); if (!iterator.hasNext()) break; runningLengthWord = new BufferedRunningLengthWord(iterator.next()); } }
/** * Size in uncompressed words of the current running length word. * * @return the long */ @Override public long size() { return this.brlw.size(); }
/** * Instantiates a new iterating buffered running length word. * * @param iterator iterator */ public IteratingBufferedRunningLengthWord(final EWAHIterator iterator) { this.iterator = iterator; this.brlw = new BufferedRunningLengthWord(this.iterator.next()); this.literalWordStartPosition = this.iterator.literalWords() + this.brlw.literalWordOffset; this.buffer = this.iterator.buffer(); }
@Override public void discardRunningWords() { this.brlw.runningLength = 0; if (this.brlw.getNumberOfLiteralWords() == 0) this.next(); }
/** * For internal use. (One could use the non-static discharge method * instead, but we expect them to be slower.) * * @param initialWord the initial word * @param iterator the iterator * @param container the container */ private static void discharge(final BufferedRunningLengthWord initialWord, final EWAHIterator iterator, final BitmapStorage container) { BufferedRunningLengthWord runningLengthWord = initialWord; for (; ; ) { final long runningLength = runningLengthWord.getRunningLength(); container.addStreamOfEmptyWords(runningLengthWord.getRunningBit(), runningLength); container.addStreamOfLiteralWords(iterator.buffer(), iterator.literalWords() + runningLengthWord.literalWordOffset, runningLengthWord.getNumberOfLiteralWords() ); if (!iterator.hasNext()) break; runningLengthWord = new BufferedRunningLengthWord(iterator.next()); } }
/** * Discard first words, iterating to the next running length word if * needed. * * @param x the number of words to be discarded */ @Override public void discardFirstWords(long x) { while (x > 0) { if (this.brlw.runningLength > x) { this.brlw.runningLength -= x; return; } x -= this.brlw.runningLength; this.brlw.runningLength = 0; long toDiscard = x > this.brlw.numberOfLiteralWords ? this.brlw.numberOfLiteralWords : x; this.literalWordStartPosition += toDiscard; this.brlw.numberOfLiteralWords -= toDiscard; x -= toDiscard; if ((x > 0) || (this.brlw.size() == 0)) { if (!this.iterator.hasNext()) { break; } this.brlw.reset(this.iterator.next()); this.literalWordStartPosition = this.iterator .literalWords(); } } }
/** * Size in uncompressed words of the current running length word. * * @return the long */ @Override public long size() { return this.brlw.size(); }
/** * Instantiates a new iterating buffered running length word. * * @param iterator iterator */ public IteratingBufferedRunningLengthWord(final EWAHIterator iterator) { this.iterator = iterator; this.brlw = new BufferedRunningLengthWord(this.iterator.next()); this.literalWordStartPosition = this.iterator.literalWords() + this.brlw.literalWordOffset; this.buffer = this.iterator.buffer(); }
@Override public void discardRunningWords() { this.brlw.runningLength = 0; if (this.brlw.getNumberOfLiteralWords() == 0) this.next(); }
@Override public String toString() { return "running bit = " + getRunningBit() + " running length = " + getRunningLength() + " number of lit. words " + getNumberOfLiteralWords(); }
/** * Reset the values of this running length word so that it has the same * values as the other running length word. * * @param rlw the other running length word */ public void reset(final RunningLengthWord rlw) { reset(rlw.buffer.getWord(rlw.position)); }
@Override public IteratingBufferedRunningLengthWord clone() throws CloneNotSupportedException { IteratingBufferedRunningLengthWord answer = (IteratingBufferedRunningLengthWord) super .clone(); answer.brlw = this.brlw.clone(); answer.iterator = this.iterator.clone(); return answer; }
@Override public void discardLiteralWords(long x) { this.literalWordStartPosition += x; this.brlw.numberOfLiteralWords -= x; if (this.brlw.numberOfLiteralWords == 0) { if (!this.iterator.hasNext()) { return; } this.brlw.reset(this.iterator.next()); this.literalWordStartPosition = this.iterator.literalWords(); } } @Override
/** * Move to the next RunningLengthWord * * @return whether the move was possible */ @Override public boolean next() { if (!this.iterator.hasNext()) { this.brlw.numberOfLiteralWords = 0; this.brlw.runningLength = 0; return false; } this.brlw.reset(this.iterator.next()); this.literalWordStartPosition = this.iterator.literalWords(); // + // this.brlw.literalWordOffset // ==0 return true; }
/** * Move to the next RunningLengthWord * * @return whether the move was possible */ @Override public boolean next() { if (!this.iterator.hasNext()) { this.brlw.numberOfLiteralWords = 0; this.brlw.runningLength = 0; return false; } this.brlw.reset(this.iterator.next()); this.literalWordStartPosition = this.iterator.literalWords(); // + // this.brlw.literalWordOffset // ==0 return true; }