pub struct HuffmanTree {
pub nodes: Vec<HuffNode>,
/* private fields */
}Expand description
The full Huffman tree stored as a flat node array.
Fields§
§nodes: Vec<HuffNode>Implementations§
Source§impl HuffmanTree
impl HuffmanTree
Sourcepub fn build(freq: &[u64; 256]) -> Option<Self>
pub fn build(freq: &[u64; 256]) -> Option<Self>
Build a Huffman tree from a frequency array (indexed by symbol 0..=255).
Returns None if all frequencies are zero.
Sourcepub fn code_lengths(&self) -> [u8; 256]
pub fn code_lengths(&self) -> [u8; 256]
Extract code lengths per symbol by walking the tree. Returns an array of 256 code lengths.
Trait Implementations§
Source§impl Clone for HuffmanTree
impl Clone for HuffmanTree
Source§fn clone(&self) -> HuffmanTree
fn clone(&self) -> HuffmanTree
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for HuffmanTree
impl RefUnwindSafe for HuffmanTree
impl Send for HuffmanTree
impl Sync for HuffmanTree
impl Unpin for HuffmanTree
impl UnsafeUnpin for HuffmanTree
impl UnwindSafe for HuffmanTree
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more