[−][src]Struct huffman_compress::CodeBuilder
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: 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)>,
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(&self) -> 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]
fn default() -> 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]
fn from_iter<T>(weights: T) -> CodeBuilder<K, W> where
T: IntoIterator<Item = (K, W)>,
[src]
T: IntoIterator<Item = (K, W)>,
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)>,
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,
Blanket Implementations
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> From<T> for T
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,