edu.berkeley.nlp.lm.bits
Class BitStream

java.lang.Object
  extended by edu.berkeley.nlp.lm.bits.BitStream

public final class BitStream
extends Object

Wraps a portion of a long[] array with iterator-like functionality over a stream of bits.

Author:
adampauls

Constructor Summary
BitStream(LongArray data, long start, int startBit, int numBits)
           
 
Method Summary
 void advance(int n)
          Advances without returning any bits.
 boolean finished()
           
 void mark()
          Sets a mark at the current bit that can be returned to using rewindToMark.
 long next(int n)
          Read and return next n bits.
 boolean nextBit()
           
 int nextConsecutiveZeros()
          Reads a string of zeros followed by a 1.
 int numBitsLeft()
           
 void rewind(int i)
           
 void rewindToMark()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BitStream

public BitStream(LongArray data,
                 long start,
                 int startBit,
                 int numBits)
Method Detail

nextBit

public boolean nextBit()

nextConsecutiveZeros

public int nextConsecutiveZeros()
Reads a string of zeros followed by a 1.

Returns:
the number of consecutive zeros (plus 1)

next

public long next(int n)
Read and return next n bits.

Parameters:
n -
Returns:

finished

public boolean finished()

rewind

public void rewind(int i)

numBitsLeft

public int numBitsLeft()

advance

public void advance(int n)
Advances without returning any bits.

Parameters:
n -

mark

public void mark()
Sets a mark at the current bit that can be returned to using rewindToMark.


rewindToMark

public void rewindToMark()