2 releases

Uses old Rust 2015

0.1.1 Mar 22, 2023
0.1.0 May 5, 2021

#842 in Data structures

Download history 218/week @ 2023-12-14 154/week @ 2023-12-21 79/week @ 2023-12-28 142/week @ 2024-01-04 230/week @ 2024-01-11 228/week @ 2024-01-18 308/week @ 2024-01-25 283/week @ 2024-02-01 371/week @ 2024-02-08 312/week @ 2024-02-15 365/week @ 2024-02-22 368/week @ 2024-02-29 514/week @ 2024-03-07 544/week @ 2024-03-14 621/week @ 2024-03-21 349/week @ 2024-03-28

2,088 downloads per month
Used in 10 crates (3 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

~175KB