Aleph-w 7.10.0
A C++ Library for Data Structures and Algorithms
Loading...
Searching...
No Matches
Aleph::adaptive_huffman_detail::Model Struct Reference

#include <Adaptive_Huffman.H>

Collaboration diagram for Aleph::adaptive_huffman_detail::Model:
[legend]

Classes

struct  Node
 

Public Member Functions

 Model () noexcept
 Construct the initial tree containing only NYT.
 
void reset () noexcept
 Restore the initial tree in O(alphabet_size) time.
 
void check_capacity () const
 Reject an update that would overflow the frequency counters.
 
int block_leader (const int node) const noexcept
 Find the highest-order node of a node's weight block.
 
void swap_nodes (const int a, const int b) noexcept
 Exchange two non-ancestor subtrees and their order numbers.
 
void update (const unsigned char symbol) noexcept
 Insert an unseen byte or increment an existing byte's path.
 

Public Attributes

Node nodes [max_nodes] = {}
 Stable node storage.
 
int by_order [max_nodes] = {}
 Order-to-node index.
 
int leaves [alphabet_size] = {}
 Byte-to-leaf index, or -1 if unseen.
 
int nyt = root
 Current NYT node index.
 
int used = 1
 Number of active nodes.
 
size_t distinct = 0
 Number of bytes seen so far.
 

Static Public Attributes

static constexpr int alphabet_size = 256
 Number of possible bytes.
 
static constexpr int max_nodes = 2 * alphabet_size + 1
 Including NYT.
 
static constexpr int root = 0
 Stable root node index.
 

Detailed Description

Definition at line 67 of file Adaptive_Huffman.H.

Constructor & Destructor Documentation

◆ Model()

Aleph::adaptive_huffman_detail::Model::Model ( )
inlinenoexcept

Construct the initial tree containing only NYT.

Definition at line 102 of file Adaptive_Huffman.H.

References reset().

Member Function Documentation

◆ block_leader()

int Aleph::adaptive_huffman_detail::Model::block_leader ( const int  node) const
inlinenoexcept

Find the highest-order node of a node's weight block.

Parameters
nodeIndex of the current node.
Returns
Index of the block leader.
Note
O(log alphabet_size). Only the suffix starting at node is searched: an incremented NYT sibling can temporarily precede its not-yet-incremented parent, but this suffix stays sorted.

Definition at line 140 of file Adaptive_Huffman.H.

References by_order, Aleph::low(), max_nodes, nodes, Aleph::adaptive_huffman_detail::Model::Node::order, and Aleph::adaptive_huffman_detail::Model::Node::weight.

Referenced by update().

◆ check_capacity()

void Aleph::adaptive_huffman_detail::Model::check_capacity ( ) const
inline

Reject an update that would overflow the frequency counters.

Exceptions
std::overflow_errorif UINT64_MAX bytes were already processed.

Definition at line 127 of file Adaptive_Huffman.H.

References ah_overflow_error_if, nodes, and root.

Referenced by Aleph::Adaptive_Huffman_Decoder::decode_bit(), and Aleph::Adaptive_Huffman_Encoder::encode().

◆ reset()

void Aleph::adaptive_huffman_detail::Model::reset ( )
inlinenoexcept

Restore the initial tree in O(alphabet_size) time.

Definition at line 108 of file Adaptive_Huffman.H.

References by_order, distinct, leaves, max_nodes, nodes, nyt, Aleph::adaptive_huffman_detail::Model::Node::order, root, and used.

Referenced by Model(), Aleph::Adaptive_Huffman_Encoder::reset(), and Aleph::Adaptive_Huffman_Decoder::reset().

◆ swap_nodes()

void Aleph::adaptive_huffman_detail::Model::swap_nodes ( const int  a,
const int  b 
)
inlinenoexcept

Exchange two non-ancestor subtrees and their order numbers.

Parameters
aFirst node index (not the root).
bSecond node index (not the root or an ancestor of a).

Definition at line 157 of file Adaptive_Huffman.H.

References by_order, Aleph::adaptive_huffman_detail::Model::Node::left, nodes, Aleph::adaptive_huffman_detail::Model::Node::order, Aleph::adaptive_huffman_detail::Model::Node::parent, and Aleph::adaptive_huffman_detail::Model::Node::right.

Referenced by update().

◆ update()

void Aleph::adaptive_huffman_detail::Model::update ( const unsigned char  symbol)
inlinenoexcept

Member Data Documentation

◆ alphabet_size

constexpr int Aleph::adaptive_huffman_detail::Model::alphabet_size = 256
staticconstexpr

Number of possible bytes.

Definition at line 69 of file Adaptive_Huffman.H.

Referenced by Aleph::Adaptive_Huffman_Decoder::decode_bit(), and Aleph::Adaptive_Huffman_Encoder::encode().

◆ by_order

int Aleph::adaptive_huffman_detail::Model::by_order[max_nodes] = {}

Order-to-node index.

Definition at line 95 of file Adaptive_Huffman.H.

Referenced by block_leader(), reset(), swap_nodes(), and update().

◆ distinct

size_t Aleph::adaptive_huffman_detail::Model::distinct = 0

◆ leaves

int Aleph::adaptive_huffman_detail::Model::leaves[alphabet_size] = {}

◆ max_nodes

constexpr int Aleph::adaptive_huffman_detail::Model::max_nodes = 2 * alphabet_size + 1
staticconstexpr

Including NYT.

Definition at line 70 of file Adaptive_Huffman.H.

Referenced by block_leader(), and reset().

◆ nodes

◆ nyt

int Aleph::adaptive_huffman_detail::Model::nyt = root

Current NYT node index.

Definition at line 97 of file Adaptive_Huffman.H.

Referenced by Aleph::Adaptive_Huffman_Decoder::decode_bit(), Aleph::Adaptive_Huffman_Encoder::encode(), reset(), and update().

◆ root

◆ used

int Aleph::adaptive_huffman_detail::Model::used = 1

Number of active nodes.

Definition at line 98 of file Adaptive_Huffman.H.

Referenced by reset(), and update().


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