HikoGUI
A low latency retained GUI
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions
hi::v1::huffman_tree< T > Class Template Reference

Public Member Functions

void add (int symbol, int code, int code_length) noexcept
 Add a symbol to the huffman_tree.
 
state_t start () const noexcept
 
int get (bool code_bit, state_t &state) const
 Get a symbol from the huffman-tree.
 
std::size_t get_symbol (std::span< std::byte const > bytes, std::size_t &bit_offset) const noexcept
 

Static Public Member Functions

static huffman_tree from_lengths (uint8_t const *lengths, std::size_t nr_symbols)
 Build a canonical-huffman table from a set of lengths.
 
static huffman_tree from_lengths (std::vector< uint8_t > const &lengths)
 

Member Function Documentation

◆ add()

template<typename T >
void hi::v1::huffman_tree< T >::add ( int symbol,
int code,
int code_length )
inlinenoexcept

Add a symbol to the huffman_tree.

◆ from_lengths()

template<typename T >
static huffman_tree hi::v1::huffman_tree< T >::from_lengths ( uint8_t const * lengths,
std::size_t nr_symbols )
inlinestatic

Build a canonical-huffman table from a set of lengths.

◆ get()

template<typename T >
int hi::v1::huffman_tree< T >::get ( bool code_bit,
state_t & state ) const
inline

Get a symbol from the huffman-tree.

Before get() is called use start() to create a state to pass between invocations. State is invalid after get() returns a symbol or throws.

Parameters
code_bitThe next bit from the huffman encoded stream.
stateThe state carried between invocations
See also
start().
Returns
Positive numbers are symbols, negative means more code_bits are needed.
Exceptions
parse-erroron invalid code-bit sequence.

The documentation for this class was generated from the following file: