Class Huffman


  • public class Huffman
    extends Object
    Huffman tree builder
    Author:
    Adam Gibson
    • Field Detail

      • MAX_CODE_LENGTH

        public final int MAX_CODE_LENGTH
    • Constructor Detail

      • Huffman

        public Huffman​(Collection<? extends SequenceElement> words,
                       int CODE_LENGTH)
        Builds Huffman tree for collection of SequenceElements, with defined CODE_LENGTH Default CODE_LENGTH is 40
        Parameters:
        words -
        CODE_LENGTH - CODE_LENGTH defines maximum length of code path, and effectively limits vocabulary size.
    • Method Detail

      • build

        public void build()
      • applyIndexes

        public void applyIndexes​(VocabCache<? extends SequenceElement> cache)
        This method updates VocabCache and all it's elements with Huffman indexes Please note: it should be the same VocabCache as was used for Huffman tree initialization
        Parameters:
        cache - VocabCache to be updated.