Class Codec.Huffman.Coder

    • Constructor Summary

      Constructors 
      Constructor Description
      Coder​(long[] codeWord, int[] codewordLength, long[] symbol, it.unimi.dsi.fastutil.longs.Long2IntMap symbol2Rank, int escapedSymbolLength)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      int codewordLength​(long symbol)
      Returns the length of the codeword associated with the given symbol.
      long encode​(long symbol)
      Returns the codeword associated with a symbol, or −1 if the provided symbol should be escaped.
      long escape()
      Returns the escape codeword, if it exists.
      int escapedSymbolLength()
      Returns the length in bit of an escaped symbol, or zero if there are no escaped symbols.
      Codec.Huffman.Coder.Decoder getDecoder()
      Return a decoder associated with this coder.
      int maxCodewordLength()
      Returns the maximum length of a codeword (including escaped symbols).
      • Methods inherited from class java.lang.Object

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

      • Coder

        public Coder​(long[] codeWord,
                     int[] codewordLength,
                     long[] symbol,
                     it.unimi.dsi.fastutil.longs.Long2IntMap symbol2Rank,
                     int escapedSymbolLength)
    • Method Detail

      • encode

        public long encode​(long symbol)
        Description copied from interface: Codec.Coder
        Returns the codeword associated with a symbol, or −1 if the provided symbol should be escaped.

        If a symbol needs to be escaped, it must be encoded using the escape codeword followed by the symbol written in a field of Codec.Coder.escapedSymbolLength() bits.

        Specified by:
        encode in interface Codec.Coder
        Parameters:
        symbol - a symbol.
        Returns:
        the associated codeword.
      • codewordLength

        public int codewordLength​(long symbol)
        Description copied from interface: Codec.Coder
        Returns the length of the codeword associated with the given symbol.

        For escaped symbols, the returned values is the length of the escape codeword plus Codec.Coder.escapedSymbolLength().

        Specified by:
        codewordLength in interface Codec.Coder
        Parameters:
        symbol - a symbol provided at construction time.
        Returns:
        the length of the codeword associated with the given symbol.
      • maxCodewordLength

        public int maxCodewordLength()
        Description copied from interface: Codec.Coder
        Returns the maximum length of a codeword (including escaped symbols).
        Specified by:
        maxCodewordLength in interface Codec.Coder
        Returns:
        the maximum length of a codeword (including escaped symbols).
      • escapedSymbolLength

        public int escapedSymbolLength()
        Description copied from interface: Codec.Coder
        Returns the length in bit of an escaped symbol, or zero if there are no escaped symbols.
        Specified by:
        escapedSymbolLength in interface Codec.Coder
        Returns:
        the length in bit of an escaped symbol, or zero if there are no escaped symbols.