Class Codec.Huffman

  • All Implemented Interfaces:
    Codec
    Enclosing interface:
    Codec

    public static class Codec.Huffman
    extends Object
    implements Codec
    A Huffman codec with length-limiting capabilities and a fast canonical decoder.
    • Constructor Detail

      • Huffman

        public Huffman​(int maxDecodingTableLength,
                       double entropyThreshold)
        Creates a new Huffman codec with specified limit and entropy threshold.
        Parameters:
        maxDecodingTableLength - a hard limit for the length of the decoding table.
        entropyThreshold - the decoding table will be truncated if the accumulated entropy (starting from the most frequent symbols) exceeds this fraction of the overall entropy.
      • Huffman

        public Huffman​(int maxDepth)
        Creates a new Huffman codec with specified limit and entropy threshold equal to 0.999.
        Parameters:
        maxDecodingTableLength - a hard limit for the length of the decoding table.
      • Huffman

        public Huffman()
        Creates a new Huffman codec no length limitations.
    • Method Detail

      • getCoder

        public Codec.Huffman.Coder getCoder​(Long2LongMap frequencies)
        Description copied from interface: Codec
        Returns a coder for a specific map from symbols to frequencies.

        Note that even instantaneous codes (such as Codec.Unary) need to know the set of symbols, as the returned coder needs to known the maximum codeword length.

        Specified by:
        getCoder in interface Codec
        Parameters:
        frequencies - a map from symbols (longs) to frequencies (longs).
        Returns:
        a coder for the given map.