pub struct Bimap<K, V, S = RandomState> { /* private fields */ }Implementations§
Source§impl<K, V> Bimap<K, V, RandomState>
impl<K, V> Bimap<K, V, RandomState>
Source§impl<K, V, S> Bimap<K, V, S>
impl<K, V, S> Bimap<K, V, S>
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>(&self, k: &KeyBorrow) -> Option<&V>
pub fn get_fwd<KeyBorrow>(&self, k: &KeyBorrow) -> Option<&V>
Gets the value corresponding to a key.
Sourcepub fn get_rev<ValBorrow>(&self, v: &ValBorrow) -> Option<&K>
pub fn get_rev<ValBorrow>(&self, v: &ValBorrow) -> Option<&K>
Gets the key corresponding to a value.
Sourcepub fn remove_fwd<KeyBorrow>(&mut self, k: &KeyBorrow) -> V
pub fn remove_fwd<KeyBorrow>(&mut self, k: &KeyBorrow) -> V
Removes the (key, value) pair with the given key; returns the corresponding value.
Sourcepub fn remove_rev<ValBorrow>(&mut self, v: &ValBorrow) -> K
pub fn remove_rev<ValBorrow>(&mut self, v: &ValBorrow) -> K
Removes the (key, value) pair with the given value; returns the corresponding key.
Sourcepub fn contains_fwd<KeyBorrow>(&self, k: &KeyBorrow) -> bool
pub fn contains_fwd<KeyBorrow>(&self, k: &KeyBorrow) -> bool
Returns whether the bimap contains a (key, value) pair with the given key.
Sourcepub fn contains_rev<ValBorrow>(&self, v: &ValBorrow) -> bool
pub fn contains_rev<ValBorrow>(&self, v: &ValBorrow) -> bool
Returns whether the bimap contains a (key, value) pair with the given value.
Trait Implementations§
Source§impl<K, V, S> FromIterator<(K, V)> for Bimap<K, V, S>
impl<K, V, S> FromIterator<(K, V)> for Bimap<K, V, S>
Source§impl<K, V, S> IntoIterator for Bimap<K, V, S>
impl<K, V, S> IntoIterator for Bimap<K, V, S>
Auto Trait Implementations§
impl<K, V, S> Freeze for Bimap<K, V, S>where
S: Freeze,
impl<K, V, S> RefUnwindSafe for Bimap<K, V, S>
impl<K, V, S> Send for Bimap<K, V, S>
impl<K, V, S> Sync for Bimap<K, V, S>
impl<K, V, S> Unpin for Bimap<K, V, S>
impl<K, V, S> UnsafeUnpin for Bimap<K, V, S>where
S: UnsafeUnpin,
impl<K, V, S> UnwindSafe for Bimap<K, V, S>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more