Class CodeWordCoder

    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected BitVector[] codeWord
      The array of codewords of this coder.
    • Constructor Summary

      Constructors 
      Constructor Description
      CodeWordCoder​(BitVector[] codeWord)
      Creates a new codeword-based coder using the given vector of codewords.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      BitVector[] codeWords()
      Provides access to the codewords.
      it.unimi.dsi.fastutil.booleans.BooleanIterator encode​(int symbol)
      Encodes a symbol.
      int encode​(int symbol, OutputBitStream obs)
      Encodes a symbol.
      it.unimi.dsi.fastutil.booleans.BooleanIterator flush()
      Flushes the coder.
      int flush​(OutputBitStream unused)
      Flushes the coder.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • codeWord

        protected final BitVector[] codeWord
        The array of codewords of this coder.
    • Constructor Detail

      • CodeWordCoder

        public CodeWordCoder​(BitVector[] codeWord)
        Creates a new codeword-based coder using the given vector of codewords. The coder will be able to encode symbols numbered from 0 to codeWord.length-1, included.
        Parameters:
        codeWord - a vector of codewords.
    • Method Detail

      • encode

        public it.unimi.dsi.fastutil.booleans.BooleanIterator encode​(int symbol)
        Description copied from interface: Coder
        Encodes a symbol.
        Specified by:
        encode in interface Coder
        Parameters:
        symbol - a symbol.
        Returns:
        a boolean iterator returning the bits coding symbol.
      • encode

        public int encode​(int symbol,
                          OutputBitStream obs)
                   throws java.io.IOException
        Description copied from interface: Coder
        Encodes a symbol.
        Specified by:
        encode in interface Coder
        Parameters:
        symbol - a symbol.
        obs - the output bit stream where the encoded symbol will be written.
        Returns:
        the number of bits written.
        Throws:
        java.io.IOException
      • flush

        public int flush​(OutputBitStream unused)
        Description copied from interface: Coder
        Flushes the coder. Warning: this method will not flush obs.
        Specified by:
        flush in interface Coder
        Parameters:
        unused - the output bit stream where the flushing bits will be written.
        Returns:
        the number of bits written to flush the coder.
      • flush

        public it.unimi.dsi.fastutil.booleans.BooleanIterator flush()
        Description copied from interface: Coder
        Flushes the coder.
        Specified by:
        flush in interface Coder
        Returns:
        a boolean iterator returning the bits used to flush this coder.
      • codeWords

        public BitVector[] codeWords()
        Description copied from interface: PrefixCoder
        Provides access to the codewords. Warning: bit 0 of each bit vector returned by PrefixCoder.codeWords() is the first (leftmost) bit of the corresponding codeword: in other words, codewords are stored in right-to-left fashion.
        Specified by:
        codeWords in interface PrefixCoder
        Returns:
        the codewords.