Struct huffman_compress::CodeBuilder
[−]
[src]
pub struct CodeBuilder<K: Ord + Clone, W: Saturating + Ord> { /* fields omitted */ }
Collects information about symbols and their weights used to construct a Huffman code.
Stability
The constructed code is guaranteed to be deterministic and stable across semver compatible releases if:
- There is a strict order on the symbols
K
. - No duplicate symbols are added.
The ordering of symbols will be used to break ties when weights are equal.
Methods
impl<K: Ord + Clone, W: Saturating + Ord> CodeBuilder<K, W>
[src]
pub fn new() -> CodeBuilder<K, W>
[src]
Creates a new, empty CodeBuilder<K, W>
.
pub fn with_capacity(capacity: usize) -> CodeBuilder<K, W>
[src]
Creates a new, empty CodeBuilder<K, W>
and preallocates space
for capacity
symbols.
pub fn push(&mut self, symbol: K, weight: W)
[src]
Adds a symbol and weight pair.
pub fn finish(self) -> (Book<K>, Tree<K>)
[src]
Trait Implementations
impl<K: Debug + Ord + Clone, W: Debug + Saturating + Ord> Debug for CodeBuilder<K, W>
[src]
fn fmt(&self, __arg_0: &mut Formatter) -> Result
[src]
Formats the value using the given formatter. Read more
impl<K: Clone + Ord + Clone, W: Clone + Saturating + Ord> Clone for CodeBuilder<K, W>
[src]
fn clone(&self) -> CodeBuilder<K, W>
[src]
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
impl<K: Ord + Clone, W: Saturating + Ord> Default for CodeBuilder<K, W>
[src]
fn default() -> CodeBuilder<K, W>
[src]
Returns the "default value" for a type. Read more
impl<K: Ord + Clone, W: Saturating + Ord> FromIterator<(K, W)> for CodeBuilder<K, W>
[src]
fn from_iter<T>(weights: T) -> CodeBuilder<K, W> where
T: IntoIterator<Item = (K, W)>,
[src]
T: IntoIterator<Item = (K, W)>,
Creates a value from an iterator. Read more
impl<K: Ord + Clone, W: Saturating + Ord> Extend<(K, W)> for CodeBuilder<K, W>
[src]
fn extend<T>(&mut self, weights: T) where
T: IntoIterator<Item = (K, W)>,
[src]
T: IntoIterator<Item = (K, W)>,
Extends a collection with the contents of an iterator. Read more
impl<'a, K: Ord + Clone, W: Saturating + Ord + Clone> FromIterator<(&'a K, &'a W)> for CodeBuilder<K, W>
[src]
fn from_iter<T>(weights: T) -> CodeBuilder<K, W> where
T: IntoIterator<Item = (&'a K, &'a W)>,
[src]
T: IntoIterator<Item = (&'a K, &'a W)>,
Creates a value from an iterator. Read more
impl<'a, K: Ord + Clone, W: Saturating + Ord + Clone> Extend<(&'a K, &'a W)> for CodeBuilder<K, W>
[src]
Auto Trait Implementations
impl<K, W> Send for CodeBuilder<K, W> where
K: Send,
W: Send,
K: Send,
W: Send,
impl<K, W> Sync for CodeBuilder<K, W> where
K: Sync,
W: Sync,
K: Sync,
W: Sync,