libfly  6.2.2
C++20 utility library for Linux, macOS, and Windows
fly::coders::HuffmanNode Struct Reference

#include <types.hpp>

Collaboration diagram for fly::coders::HuffmanNode:

Public Member Functions

 HuffmanNode () noexcept
 
HuffmanNodeoperator= (HuffmanNode &&node) noexcept
 
void become_symbol (symbol_type symbol, frequency_type frequency)
 
void become_intermediate (HuffmanNode *left, HuffmanNode *right)
 

Public Attributes

symbol_type m_symbol
 
frequency_type m_frequency
 
HuffmanNodem_left
 
HuffmanNodem_right
 

Detailed Description

Struct to store data for a single node in a Huffman tree. Huffman trees are binary trees. A node represents either a symbol from the input stream and its frequency, or the node is a junction storing the sum total of the frequencies of each node in its subtree.

Author
Timothy Flynn (trfly.nosp@m.nn89.nosp@m.@pm.m.nosp@m.e)
Version
July 7, 2019

Constructor & Destructor Documentation

◆ HuffmanNode()

fly::coders::HuffmanNode::HuffmanNode ( )
noexcept

Default constructor. Set all fields to zero/null.

Member Function Documentation

◆ become_intermediate()

void fly::coders::HuffmanNode::become_intermediate ( HuffmanNode left,
HuffmanNode right 
)

Change this node to represent an intermediate, non-symbol. Its frequency is set to the sum of its children's frequencies.

Parameters
leftPointer to the intermediate's left child.
rightPointer to the intermediate's right child.

◆ become_symbol()

void fly::coders::HuffmanNode::become_symbol ( symbol_type  symbol,
frequency_type  frequency 
)

Change this node to represent a symbol from the input stream.

Parameters
symbolThe symbol from the input stream.
frequencyThe frequency of the symbol in the input stream.

◆ operator=()

HuffmanNode & fly::coders::HuffmanNode::operator= ( HuffmanNode &&  node)
noexcept

Move assignment operator. Move all member variables from the given HuffmanNode instance into this instance.

Parameters
nodeThe HuffmanNode instance to move.

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