Class HuffmanCanoncialCodeGenerator<T>
- java.lang.Object
-
- htsjdk.samtools.cram.encoding.core.huffmanUtils.HuffmanCanoncialCodeGenerator<T>
-
- Type Parameters:
T- type of the symbols in the alphabet being huffman-encoded
public final class HuffmanCanoncialCodeGenerator<T> extends Object
Given a set ofHuffmanParams, creates the set of canonical codes that are be used to read/write symbols from/to an output/input stream.
-
-
Constructor Summary
Constructors Constructor Description HuffmanCanoncialCodeGenerator(HuffmanParams<T> huffmanParams)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description List<HuffmanBitCode<T>>getCanonicalCodeWords()Return the canonical code words for this helper'sHuffmanParamsas a list of HuffmanBitCodes.intgetCodeWordLenForValue(T value)Tread(BitInputStream bitInputStream)Read a single huffman-encoded symbol from a streamlongwrite(BitOutputStream bitOutputStream, T symbol)
-
-
-
Constructor Detail
-
HuffmanCanoncialCodeGenerator
public HuffmanCanoncialCodeGenerator(HuffmanParams<T> huffmanParams)
- Parameters:
huffmanParams-HuffmanParamsto use for this helper
-
-
Method Detail
-
getCanonicalCodeWords
public List<HuffmanBitCode<T>> getCanonicalCodeWords()
Return the canonical code words for this helper'sHuffmanParamsas a list of HuffmanBitCodes.- Returns:
- list of HuffmanBitCode for this helper's
HuffmanParams
-
write
public final long write(BitOutputStream bitOutputStream, T symbol)
- Parameters:
bitOutputStream- stream to which the symbol should be writtensymbol- symbol from the alphabet to be written to the stream- Returns:
- the length of the codeword that was written
-
read
public final T read(BitInputStream bitInputStream)
Read a single huffman-encoded symbol from a stream- Parameters:
bitInputStream- stream from which a symbol should read- Returns:
- symbol read from the stream
-
getCodeWordLenForValue
public int getCodeWordLenForValue(T value)
-
-