Package htsjdk.samtools.cram.encoding.core.huffmanUtils

# 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 of `HuffmanParams`, 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

Modifier and Type
Method
Description
`List<HuffmanBitCode<T>>`
`getCanonicalCodeWords()`
Return the canonical code words for this helper's `HuffmanParams` as a list of HuffmanBitCodes.
`int`
`getCodeWordLenForValue(T value)`
`final T`
`read(BitInputStream bitInputStream)`
Read a single huffman-encoded symbol from a stream
`final long`
`write(BitOutputStream bitOutputStream, T symbol)`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Constructor Details

### HuffmanCanoncialCodeGenerator

public HuffmanCanoncialCodeGenerator(HuffmanParams<T> huffmanParams)

Parameters:
  `huffmanParams` - `HuffmanParams` to use for this helper

## Method Details

### getCanonicalCodeWords

public List<HuffmanBitCode<T>> getCanonicalCodeWords()
Return the canonical code words for this helper's `HuffmanParams` as 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 written
  `symbol` - 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)