fn build_encoding_map(node: &Node,encoding_map: &mut HashMap<u8, String>,code: String){
    match node.value {
        Some(value) => {
            encoding_map.insert(value, code);
        }
        None => {
            match &node.left {
                Some(left) => {
                    build_encoding_map(left,encoding_map,code.clone() + "0");
                }
                None => {}
            }
            match &node.right {
                Some(right) => {
                    build_encoding_map(right,encoding_map,code.clone() + "1");
                }
                None => {}
            }
        }
    }

}
//Creates a Hash Map of the encoding of every u8 within a given Huffman Tree. Left node edges are 0s and right node edges are 1s
Creates a Hash Map of the encoding of every u8 within a given Huffman Tree. Left node edges are 0s and right node edges are 1s
Creates a Hash Map of the encoding of every u8 within a given Huffman Tree . Left node edges are 0s and right node edges are 1s
fn build_encoding_map(node: &Node,encoding_map: &mut HashMap<u8, String>,code: String){
    match node.value {
        Some(value) => {
            encoding_map.insert(value, code);
        }
        None => {
            match &node.left {
                Some(left) => {
                    build_encoding_map(left,encoding_map,code.clone() + "0");
                }
                None => {}
            }
            match &node.right {
                Some(right) => {
                    build_encoding_map(right,encoding_map,code.clone() + "1");
                }
                None => {}
            }
        }
    }
}
fn build_encoding_map ( node : & Node , encoding_map : & mut HashMap < u8 , String > , code : String ) { match node . value { Some ( value ) => { encoding_map . insert ( value , code ) ; } None => { match & node . left { Some ( left ) => { build_encoding_map ( left , encoding_map , code . clone ( ) + " " ) ; } None => { } } match & node . right { Some ( right ) => { build_encoding_map ( right , encoding_map , code . clone ( ) + " " ) ; } None => { } } } } }
Creates a Hash Map of the encoding of every u8 within a given Huffman Tree.
Creates a Hash Map of the encoding of every u8 within a given Huffman Tree .
node
&Node
encoding_map
&mut HashMap<u8, String>
code
String
node
&Node
encoding_map
&mut HashMap<u8, String>
code
String