Struct bidirectional_map::Bimap
source · pub struct Bimap<K, V, S = RandomState> { /* private fields */ }
Implementations
sourceimpl<K, V, S> Bimap<K, V, S>where
K: Eq + Hash + Clone,
V: Eq + Hash + Clone,
S: BuildHasher + Clone + Default,
impl<K, V, S> Bimap<K, V, S>where
K: Eq + Hash + Clone,
V: Eq + Hash + Clone,
S: BuildHasher + Clone + Default,
sourcepub fn with_hasher(hash_builder: S) -> Self
pub fn with_hasher(hash_builder: S) -> Self
Creates a Bimap
with the given hasher.
sourcepub fn from_hash_map(fwd: HashMap<K, V, S>) -> Self
pub fn from_hash_map(fwd: HashMap<K, V, S>) -> Self
Creates a bimap from a HashMap
.
sourcepub fn insert(&mut self, k: K, v: V)
pub fn insert(&mut self, k: K, v: V)
Inserts a (key, value) pair into the bimap. Panics if either the key or value is already
present in the bimap; to change a key or value, call either remove_fwd
or
remove_rev
before inserting the new (key, value) pair.
sourcepub fn get_fwd<KeyBorrow: ?Sized>(&self, k: &KeyBorrow) -> Option<&V>where
K: Borrow<KeyBorrow>,
KeyBorrow: Hash + Eq,
pub fn get_fwd<KeyBorrow: ?Sized>(&self, k: &KeyBorrow) -> Option<&V>where
K: Borrow<KeyBorrow>,
KeyBorrow: Hash + Eq,
Gets the value corresponding to a key.
sourcepub fn get_rev<ValBorrow: ?Sized>(&self, v: &ValBorrow) -> Option<&K>where
V: Borrow<ValBorrow>,
ValBorrow: Hash + Eq,
pub fn get_rev<ValBorrow: ?Sized>(&self, v: &ValBorrow) -> Option<&K>where
V: Borrow<ValBorrow>,
ValBorrow: Hash + Eq,
Gets the key corresponding to a value.
sourcepub fn remove_fwd<KeyBorrow: ?Sized>(&mut self, k: &KeyBorrow) -> Vwhere
K: Borrow<KeyBorrow>,
KeyBorrow: Hash + Eq,
pub fn remove_fwd<KeyBorrow: ?Sized>(&mut self, k: &KeyBorrow) -> Vwhere
K: Borrow<KeyBorrow>,
KeyBorrow: Hash + Eq,
Removes the (key, value) pair with the given key; returns the corresponding value.
sourcepub fn remove_rev<ValBorrow: ?Sized>(&mut self, v: &ValBorrow) -> Kwhere
V: Borrow<ValBorrow>,
ValBorrow: Hash + Eq,
pub fn remove_rev<ValBorrow: ?Sized>(&mut self, v: &ValBorrow) -> Kwhere
V: Borrow<ValBorrow>,
ValBorrow: Hash + Eq,
Removes the (key, value) pair with the given value; returns the corresponding key.
sourcepub fn contains_fwd<KeyBorrow: ?Sized>(&self, k: &KeyBorrow) -> boolwhere
K: Borrow<KeyBorrow>,
KeyBorrow: Hash + Eq,
pub fn contains_fwd<KeyBorrow: ?Sized>(&self, k: &KeyBorrow) -> boolwhere
K: Borrow<KeyBorrow>,
KeyBorrow: Hash + Eq,
Returns whether the bimap contains a (key, value) pair with the given key.
Trait Implementations
Auto Trait Implementations
impl<K, V, S> RefUnwindSafe for Bimap<K, V, S>where
K: RefUnwindSafe,
S: RefUnwindSafe,
V: RefUnwindSafe,
impl<K, V, S> Send for Bimap<K, V, S>where
K: Send,
S: Send,
V: Send,
impl<K, V, S> Sync for Bimap<K, V, S>where
K: Sync,
S: Sync,
V: Sync,
impl<K, V, S> Unpin for Bimap<K, V, S>where
K: Unpin,
S: Unpin,
V: Unpin,
impl<K, V, S> UnwindSafe for Bimap<K, V, S>where
K: UnwindSafe,
S: UnwindSafe,
V: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more