#hash-map #map #two-way #bidirectional #serialization #multimap

bisetmap

BisetMap is a fast and thread-safe two-way hash map of sets. It is best suited where you need to associate two collumns uniquely. Each key is associated to one or more other unique values. The structure is interior mutable and all operations are thread safe. Each clone provides access to the same underlying data. Serialize and Deserialize from serde are also implemented.

7 releases

Uses old Rust 2015

0.1.6 Nov 9, 2017
0.1.5 Nov 9, 2017

#2351 in Data structures

Download history 76/week @ 2024-03-13 92/week @ 2024-03-20 59/week @ 2024-03-27 144/week @ 2024-04-03 71/week @ 2024-04-10 112/week @ 2024-04-17 271/week @ 2024-04-24 180/week @ 2024-05-01 280/week @ 2024-05-08 259/week @ 2024-05-15 257/week @ 2024-05-22 312/week @ 2024-05-29 223/week @ 2024-06-05 302/week @ 2024-06-12 150/week @ 2024-06-19 247/week @ 2024-06-26

971 downloads per month
Used in mapped_futures

MIT license

21KB
229 lines

crates.io Documentation

BisetMap

BisetMap is a fast and thread-safe two-way hash map of sets for Rust. It is best suited where you need to associate two collumns uniquely. Each key is associated to one or more other unique values.

The structure is interior mutable and all operations are thread safe. Each clone provides access to the same underlying data. Serialize and Deserialize from serde are also implemented.

Usage

To use BisetMap in your Rust project, add bisetmap = 0.1 to the dependencies section of your Cargo.toml. See the docs for more details and example code.

Examples

use bisetmap::BisetMap;

let subscriptions = BisetMap::new();

// insert client-ids and subscription topics
subscriptions.insert("Bob", "Tech");
subscriptions.insert("Bob", "Math");
subscriptions.insert("Alice", "Tech");
subscriptions.insert("Alice", "Romance");

// retrieve topic by client-id (left to right)
assert_eq!(subscriptions.get(&"Bob"), ["Math", "Tech"]);
assert_eq!(subscriptions.get(&"Alice"), ["Romance", "Tech"]);

// retrieve clients by topic (right to left)
assert_eq!(subscriptions.rev_get(&"Tech"), ["Alice", "Bob"]);
assert_eq!(subscriptions.rev_get(&"Math"), ["Bob"]);

// check membership
assert!(subscriptions.contains(&"Bob", &"Math"));
assert!(!subscriptions.contains(&"Bob", &"Romance"));

// check key/value existence
assert!(subscriptions.key_exists(&"Alice"));
assert!(subscriptions.value_exists(&"Tech"));

License

BisetMap is licensed under the MIT license.

Dependencies

~110–350KB