Function lib_rapid::compsci::compression::huffman::assign_codes[][src]

pub fn assign_codes(
    root: &Box<Node>,
    hashmap: &mut HashMap<char, BitVec>,
    bitvec: &mut BitVec
)
Expand description

Assigns Huffman-codes to each character.

Arguments

  • root - The Huffman tree.
  • hashmap - The variable in which the result is stored.
  • bitvec - A temporary BitVec.

Returns

Nothing.

Examples

use lib_rapid::compsci::compression::huffman::{get_root, assign_codes};
use bit_vec::BitVec;
use std::collections::HashMap;

let s = "Lorem Ipsum";
let root = get_root(s);
let mut char_codes:HashMap<char, BitVec> = HashMap::new();
assign_codes(&root, &mut char_codes, &mut BitVec::new()); // Assigns codes to characters of s and stores them in char_codes.