Crates.io | btreemultimap |
lib.rs | btreemultimap |
version | 0.1.1 |
source | src |
created_at | 2021-05-05 20:33:40.569142 |
updated_at | 2023-03-22 00:35:27.76272 |
description | A multimap implementation with range support. |
homepage | |
repository | https://github.com/john-sharratt/btree-multimap.git |
max_upload_size | |
id | 393558 |
size | 68,336 |
This is a sorted multimap implementation with range support for Rust. Implemented as a thin wrapper around std::collections::BTreeMap.
extern crate multimap;
use btreemultimap::BTreeMultiMap;
fn main () {
let mut map = BTreeMultiMap::new();
map.insert(3, "a");
map.insert(5, "b");
map.insert(5, "c");
map.insert(8, "c");
map.insert(9, "d");
assert_eq!(map[3], "a");
assert_eq!(map.get(5), Some(&"b"));
assert_eq!(map.get_vec(5), Some(&vec!["b", "c"]));
for (&key, &value) in map.range((Included(&4), Included(&8))) {
println!("{}: {}", key, value);
}
let mut iter = map.range(4..=8);
assert_eq!(Some((&5, &"b")), iter.next());
assert_eq!(Some((&5, &"c")), iter.next());
assert_eq!(Some((&8, &"c")), iter.next());
assert_eq!(None, iter.next());
}
Licensed under either of
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.