bst-hashmap

Crates.iobst-hashmap
lib.rsbst-hashmap
version0.1.2
created_at2025-06-22 16:56:22.367918+00
updated_at2025-06-22 17:21:23.995069+00
descriptionA binary tree implementation with a hashmap-inspired interface.
homepage
repositoryhttps://github.com/matheus-git/bst-hashmap
max_upload_size
id1721777
size16,064
(matheus-git)

documentation

README

Bst Hashmap

rust

A binary tree implementation, with an interface imitating key-value collections like HashMap.

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.

Commit count: 0

cargo fmt