File tree Expand file tree Collapse file tree 1 file changed +3
-2
lines changed Expand file tree Collapse file tree 1 file changed +3
-2
lines changed Original file line number Diff line number Diff line change 18
18
//! # use std::error::Error;
19
19
//! #
20
20
//! # fn try_main() -> Result<(), Box<Error>> {
21
+ //! use std::iter::FromIterator;
21
22
//! use std::collections::HashMap;
22
23
//! use bit_vec::BitVec;
23
- //! use huffman_compress::{Book, Tree, codebook };
24
+ //! use huffman_compress::{CodeBuilder, Book, Tree };
24
25
//!
25
26
//! let mut weights = HashMap::new();
26
27
//! weights.insert("CG", 293);
31
32
//!
32
33
//! // Construct a Huffman code based on the weights (e.g. counts or relative
33
34
//! // frequencies).
34
- //! let (book, tree) = codebook(& weights);
35
+ //! let (book, tree) = CodeBuilder::from_iter( weights).finish( );
35
36
//!
36
37
//! // More frequent symbols will be encoded with fewer bits.
37
38
//! assert!(book.get("CG").map_or(0, |cg| cg.len()) <
You can’t perform that action at this time.
0 commit comments