#range #b-tree #btree-map

btreemultimap

A multimap implementation with range support

2 releases

Uses old Rust 2015

0.1.1 Mar 22, 2023
0.1.0 May 5, 2021

#17 in #btree-map

Download history 359/week @ 2024-07-20 332/week @ 2024-07-27 491/week @ 2024-08-03 401/week @ 2024-08-10 489/week @ 2024-08-17 485/week @ 2024-08-24 387/week @ 2024-08-31 451/week @ 2024-09-07 202/week @ 2024-09-14 602/week @ 2024-09-21 487/week @ 2024-09-28 454/week @ 2024-10-05 321/week @ 2024-10-12 393/week @ 2024-10-19 376/week @ 2024-10-26 415/week @ 2024-11-02

1,561 downloads per month
Used in 8 crates (2 directly)

MIT/Apache

55KB
1K SLoC

Multimap implementation for Rust

This is a sorted multimap implementation with range support for Rust. Implemented as a thin wrapper around std::collections::BTreeMap.

Example

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());
}

License

Licensed under either of

Contribution

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.

Dependencies

~165KB