simple-bst 0.1.2

A bst implementation.
Documentation
  • Coverage
  • 0%
    0 out of 9 items documented0 out of 6 items with examples
  • Size
  • Source code size: 15.49 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 338.55 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 10s Average build duration of successful builds.
  • all releases: 10s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • matheus-git/bst
    3 1 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • matheus-git

Bst Hashmap

rust

A binary tree implementation.

Binary trees are not recommended for production since they are not balanced. This repository is intended for study purposes only.

let mut map = BstHashmap::<i32, String>::default();

map.insert(5, "five".to_string());
map.insert(3, "three".to_string());
map.insert(7, "seven".to_string());
map.insert(6, "six".to_string());
map.insert(8, "eight".to_string());

if let Some(value) = map.search(7) {
    println!("Found key 7 with value: {}", value);
} else {
    println!("Key 7 not found");
}

if let Some((min_key, min_val)) = map.min(5) {
    println!("Min in subtree of 5: key = {}, value = {}", min_key, min_val);
}

if let Some((max_key, max_val)) = map.max(5) {
    println!("Max in subtree of 5: key = {}, value = {}", max_key, max_val);
}

map.remove(7);
println!("Removed key 7");
 
if map.search(7).is_none() {
    println!("Key 7 no longer found after removal");
}

📝 License

This project is open-source under the MIT License.