[][src]Struct huffman_compress::CodeBuilder

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]

Constructs a book and tree pair for encoding and decoding.

Trait Implementations

impl<K: Ord + Clone, W: Saturating + Ord> Extend<(K, W)> for CodeBuilder<K, W>[src]

impl<'a, K: Ord + Clone, W: Saturating + Ord + Clone> Extend<(&'a K, &'a W)> for CodeBuilder<K, W>[src]

impl<K: Clone + Ord + Clone, W: Clone + Saturating + Ord> Clone for CodeBuilder<K, W>[src]

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]

impl<K: Debug + Ord + Clone, W: Debug + Saturating + Ord> Debug for CodeBuilder<K, W>[src]

impl<K: Ord + Clone, W: Saturating + Ord> FromIterator<(K, W)> for CodeBuilder<K, W>[src]

impl<'a, K: Ord + Clone, W: Saturating + Ord + Clone> FromIterator<(&'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

impl<K, W> Sync for CodeBuilder<K, W> where
    K: Sync,
    W: Sync

Blanket Implementations

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]