Crates.io | search_trees |
lib.rs | search_trees |
version | 0.0.3 |
source | src |
created_at | 2020-12-06 08:44:48.389653 |
updated_at | 2021-02-19 14:16:56.704736 |
description | Utilities for binary search tree, red-black tree, and AVL tree. |
homepage | https://crates.io/crates/search_trees |
repository | https://github.com/Leo-LiHao/search_trees |
max_upload_size | |
id | 320087 |
size | 119,289 |
Utilities for binary search tree, red-black tree, and AVL tree.
Promotional video HERE
use search_trees::prelude::*;
let mut avl = AVLTree::new(2);
avl.insert(0);
avl.delete(0);
let mut bst = BinarySearchTree::new();
bst.insert(0);
bst.delete(0);
let mut rbt = RedBlackTree::new(2);
rbt.insert(0);
rbt.delete(0);
// you can query the tree using methods like:
// - is_empty
// - contains
// - height
// - min/max
// - ...
println!("{:?}", bst.max());
println!("height: {}", bst.height());
println!("is_empty: {}", bst.is_empty());
println!("count_leaves: {}", bst.count_leaves());
println!("min: {}", bst.min().unwrap());
println!("max: {}", bst.max().unwrap());
println!("contains 1: {}", bst.contains(1));
println!("contains 10: {}", bst.contains(10));
print!("print_inorder: ");
bst.print_inorder();
Run the command line interface using
$ cargo run
Run the tests using
$ cargo test
Building the documentation using
$ cargo doc
then you can find the documentation in ./target/doc/trees/index.html,
Run the benchmarks
$ cargo bench
You can find the bench results in ./target/criterion/Compare/report/index.html
To plot pretty figures, use the script ./benches/plot_benches.py
$ cd benches
$ python plot_benches.py
You can find the figures in ./target/criterion