[][src]Struct bidirectional_map::Bimap

pub struct Bimap<K, V, S = RandomState> { /* fields omitted */ }

Implementations

impl<K, V> Bimap<K, V, RandomState> where
    K: Eq + Hash + Clone,
    V: Eq + Hash + Clone
[src]

pub fn new() -> Self[src]

Creates an empty Bimap.

impl<K, V, S> Bimap<K, V, S> where
    K: Eq + Hash + Clone,
    V: Eq + Hash + Clone,
    S: BuildHasher + Clone + Default
[src]

pub fn with_hasher(hash_builder: S) -> Self[src]

Creates a Bimap with the given hasher.

pub fn from_hash_map(fwd: HashMap<K, V, S>) -> Self[src]

Creates a bimap from a HashMap.

pub fn len(&self) -> usize[src]

Returns the number of elements in the bimap.

pub fn is_empty(&self) -> bool[src]

Returns whether the bimap is empty.

pub fn clear(&mut self)[src]

Removes all elements from the bimap.

pub fn insert(&mut self, k: K, v: V)[src]

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.

pub fn fwd(&self) -> &HashMap<K, V, S>[src]

Gets the forward HashMap.

pub fn rev(&self) -> &HashMap<V, K, S>[src]

Gets the reverse HashMap.

pub fn get_fwd<KeyBorrow: ?Sized>(&self, k: &KeyBorrow) -> Option<&V> where
    K: Borrow<KeyBorrow>,
    KeyBorrow: Hash + Eq
[src]

Gets the value corresponding to a key.

pub fn get_rev<ValBorrow: ?Sized>(&self, v: &ValBorrow) -> Option<&K> where
    V: Borrow<ValBorrow>,
    ValBorrow: Hash + Eq
[src]

Gets the key corresponding to a value.

pub fn remove_fwd<KeyBorrow: ?Sized>(&mut self, k: &KeyBorrow) -> V where
    K: Borrow<KeyBorrow>,
    KeyBorrow: Hash + Eq
[src]

Removes the (key, value) pair with the given key; returns the corresponding value.

pub fn remove_rev<ValBorrow: ?Sized>(&mut self, v: &ValBorrow) -> K where
    V: Borrow<ValBorrow>,
    ValBorrow: Hash + Eq
[src]

Removes the (key, value) pair with the given value; returns the corresponding key.

pub fn contains_fwd<KeyBorrow: ?Sized>(&self, k: &KeyBorrow) -> bool where
    K: Borrow<KeyBorrow>,
    KeyBorrow: Hash + Eq
[src]

Returns whether the bimap contains a (key, value) pair with the given key.

pub fn contains_rev<ValBorrow: ?Sized>(&self, v: &ValBorrow) -> bool where
    V: Borrow<ValBorrow>,
    ValBorrow: Hash + Eq
[src]

Returns whether the bimap contains a (key, value) pair with the given value.

pub fn iter(&self) -> Iter<'_, K, V>[src]

Iterates over all (key, value) pairs in the bimap.

Trait Implementations

impl<K: Clone, V: Clone, S: Clone> Clone for Bimap<K, V, S>[src]

impl<K: Debug, V: Debug, S: Debug> Debug for Bimap<K, V, S>[src]

impl<K, V, S> Default for Bimap<K, V, S> where
    K: Eq + Hash + Clone,
    V: Eq + Hash + Clone,
    S: BuildHasher + Clone + Default
[src]

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

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.