pub fn huffman_encode(data: &Vec<u8>) -> HuffmanData {
    let frequency_map = build_frequency_map(&data);
    let huffman_tree = build_huffman_tree(&frequency_map);
    let mut encoding_map:HashMap<u8, String> = HashMap::new();
    build_encoding_map(&huffman_tree,&mut encoding_map,"".to_string());

    let encoded_data_bin = huffman_encode_string(&data,&encoding_map);
    let padded_encoded_data_bin = pad_encoded_data(&encoded_data_bin);
    let encoded_data_u8_vec = bin_string_to_u8_vec(&padded_encoded_data_bin);
    get_stats(&data,&encoded_data_u8_vec);
    let huffman_encoded_data = HuffmanData{encoded_data: encoded_data_u8_vec,encoding_map: encoding_map};
    
    return huffman_encoded_data;
}
//Takes a String and Huffman Encodes it returning a Hex version of the string and a HashMap containing the Encoding map
Takes a String and Huffman Encodes it returning a Hex version of the string and a HashMap containing the Encoding map
Takes a String and Huffman Encodes it returning a Hex version of the string and a HashMap containing the Encoding map
pub fn huffman_encode(data: &Vec<u8>) -> HuffmanData {
    let frequency_map = build_frequency_map(&data);
    let huffman_tree = build_huffman_tree(&frequency_map);
    let mut encoding_map:HashMap<u8, String> = HashMap::new();
    build_encoding_map(&huffman_tree,&mut encoding_map,"".to_string());
    let encoded_data_bin = huffman_encode_string(&data,&encoding_map);
    let padded_encoded_data_bin = pad_encoded_data(&encoded_data_bin);
    let encoded_data_u8_vec = bin_string_to_u8_vec(&padded_encoded_data_bin);
    get_stats(&data,&encoded_data_u8_vec);
    let huffman_encoded_data = HuffmanData{encoded_data: encoded_data_u8_vec,encoding_map: encoding_map};
    return huffman_encoded_data;
}
pub fn huffman_encode ( data : & Vec < u8 > ) -> HuffmanData { let frequency_map = build_frequency_map ( & data ) ; let huffman_tree = build_huffman_tree ( & frequency_map ) ; let mut encoding_map : HashMap < u8 , String > = HashMap :: new ( ) ; build_encoding_map ( & huffman_tree , & mut encoding_map , " " . to_string ( ) ) ; let encoded_data_bin = huffman_encode_string ( & data , & encoding_map ) ; let padded_encoded_data_bin = pad_encoded_data ( & encoded_data_bin ) ; let encoded_data_u8_vec = bin_string_to_u8_vec ( & padded_encoded_data_bin ) ; get_stats ( & data , & encoded_data_u8_vec ) ; let huffman_encoded_data = HuffmanData { encoded_data : encoded_data_u8_vec , encoding_map : encoding_map } ; return huffman_encoded_data ; }
Takes a String and Huffman Encodes it returning a Hex version of the string and a HashMap containing the Encoding map
Takes a String and Huffman Encodes it returning a Hex version of the string and a HashMap containing the Encoding map
data
&Vec<u8>
data
&Vec<u8>