lib-nested/nested/src/bimap.rs

28 lines
583 B
Rust

use std::{
collections::HashMap,
hash::Hash
};
//<<<<>>>><<>><><<>><<<*>>><<>><><<>><<<<>>>>
pub struct Bimap<V: Eq + Hash, Λ: Eq + Hash> {
pub : HashMap::<V, Λ>,
pub my: HashMap::<Λ, V>
}
impl<V: Eq + Hash + Clone, Λ: Eq + Hash + Clone> Bimap<V, Λ> {
pub fn new() -> Self {
Bimap {
: HashMap::new(),
my: HashMap::new()
}
}
pub fn insert(&mut self, y: V, λ: Λ) {
self..insert(y.clone(), λ.clone());
self.my.insert(λ, y);
}
}
//<<<<>>>><<>><><<>><<<*>>><<>><><<>><<<<>>>>