Crates.io | avl |
lib.rs | avl |
version | 0.7.1 |
source | src |
created_at | 2020-08-23 14:50:42.207144 |
updated_at | 2023-04-15 07:22:52.811195 |
description | A map and a set implemented with an AVL tree. |
homepage | https://github.com/oliver-anhuth/avl |
repository | https://github.com/oliver-anhuth/avl |
max_upload_size | |
id | 279838 |
size | 138,440 |
An ordered map and set implemented with an AVL tree (nearly balanced binary search tree) in Rust.
use avl::AvlTreeMap;
let mut map = AvlTreeMap::new();
map.insert(0, "zero");
map.insert(1, "one");
map.insert(2, "two");
assert_eq!(map.get(&1), Some(&"one"));
map.remove(&1);
assert!(map.get(&1).is_none());
use avl::AvlTreeSet;
let mut set = AvlTreeSet::new();
set.insert(0);
set.insert(1);
set.insert(2);
assert_eq!(set.get(&1), Some(&1));
set.remove(&1);
assert!(set.get(&1).is_none());
This is solely to get practice with the dark art of unsafe Rust. For all common purposes one of the standard library collections should be preferable.