Class CodeByteStream


  • public class CodeByteStream
    extends Object
    • Field Detail

      • bytes

        protected byte[] bytes
      • byteOffset

        protected int byteOffset
      • bitOffset

        protected int bitOffset
      • markByteOffset

        protected int markByteOffset
      • markBitOffset

        protected int markBitOffset
    • Constructor Detail

      • CodeByteStream

        public CodeByteStream()
      • CodeByteStream

        public CodeByteStream​(byte[] bytes)
      • CodeByteStream

        public CodeByteStream​(int initialByteLength)
    • Method Detail

      • byteLength

        public int byteLength()
      • getBytes

        public byte[] getBytes​(int startOffset,
                               int endOffset)
      • grow

        protected void grow()
      • mark

        public void mark()
      • readBit

        public int readBit()
        Reads a single bit (value == 0 or == 1).
      • readBits

        public int readBits​(int numBits)
        Read up to 32 bits from the stream.
      • readByte

        public final int readByte()
      • readGamma

        public int readGamma()
        Reads a value using Gamma coding.
      • readUnary

        public int readUnary()
        Reads a value in unary.
      • reset

        public void reset()
      • reset

        public void reset​(byte[] bytes)
      • reset

        public void reset​(byte[] bytes,
                          int byteOffset)
      • resetToMark

        public boolean resetToMark()
      • skipBits

        public void skipBits​(int numBits)
      • toByteArray

        public byte[] toByteArray()
      • writeBit

        public void writeBit​(int value)
        Writes a single bit (value == 0 or == 1).
      • writeBits

        public void writeBits​(int value,
                              int numBits)
        Write up to 32 bits to the stream. The least significant numBits bits of value are written.
      • writeByte

        public void writeByte​(int value)
      • writeGamma

        public void writeGamma​(int value)
        Writes the given value using Gamma coding, in which positive integer x is represented by coding floor(log2(x) in unary followed by the value of x - 2**floor(log2(x)) in binary. The value must be >= 1.
      • writeUTF

        public void writeUTF​(char[] str,
                             int start,
                             int end)
      • writeUnary

        public void writeUnary​(int value)
        Write the given value in unary. The value must be >= 1.