multi_bimap
Many-to-many bidirectional map in Rust.
This crate provides a MultiBimap struct, a bidirectional multimap that is
implemented as two antiparallel multimaps that are kept in sync.
This structure is also known under many other names: bi-multimap, multi-bimap, or sometimes even just bimap; in set theory, it's simply called a relation; in graph theory, it's the same as a bipartite graph.
Usage
Adding dependency
First, add multi_bimap as a dependency to your Cargo.toml:
[]
= "0.2.0"
Example
A MultiBimap keeps two antiparallel multimaps in sync; each side may map a key
to multiple values. You can look up associations in either direction.
use MultiBimap;
use ;
let mut m: = new;
m.insert;
m.insert;
m.insert;
// Look up all right values for a left key.
assert_eq!;
// Look up all left values for a right key.
assert_eq!;
// Remove one association; empty keys are dropped automatically.
assert_eq!;