HikoGUI
A low latency retained GUI
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions
tt::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.
 
int get_symbol (std::span< std::byte const > bytes, ssize_t &bit_offset) const noexcept
 

Static Public Member Functions

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

Member Function Documentation

◆ add()

template<typename T >
void tt::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 tt::huffman_tree< T >::from_lengths ( int const * lengths,
ssize_t nr_symbols )
inlinestatic

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

◆ get()

template<typename T >
int tt::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: