Struct linear_collections::VecMap
source · pub struct VecMap<K: Eq, V: Sized + PartialEq> { /* private fields */ }
Expand description
A map type backed by a Vector. Useful for small collections whose size can change.
Implementations§
source§impl<K: Eq, V: Sized + PartialEq> VecMap<K, V>
impl<K: Eq, V: Sized + PartialEq> VecMap<K, V>
sourcepub fn with_capacity(capacity: usize) -> VecMap<K, V>
pub fn with_capacity(capacity: usize) -> VecMap<K, V>
Creates a new, empty VecMap with capacity set to the provide value. Calls Vec::with_capacity() internally.
sourcepub fn remove(&mut self, key: &K) -> Option<V>
pub fn remove(&mut self, key: &K) -> Option<V>
Tries to remove the value associated with the given key, returning None if it is not found.
sourcepub fn remove_entry(&mut self, key: &K) -> Option<(K, V)>
pub fn remove_entry(&mut self, key: &K) -> Option<(K, V)>
Tries to remove the entry associated with the given key, returning None if it is not found.
Trait Implementations§
source§impl<K: Eq, V: Sized + PartialEq> LinearMap<K, V> for VecMap<K, V>
impl<K: Eq, V: Sized + PartialEq> LinearMap<K, V> for VecMap<K, V>
type Backing = Vec<(K, V)>
source§fn into_inner(self) -> Self::Backing
fn into_inner(self) -> Self::Backing
Consumes self, returning the underlying store.
source§fn contains_key(&self, key: &K) -> bool
fn contains_key(&self, key: &K) -> bool
Returns true if this map contains the given key. False otherwise.
source§fn contains_value(&self, value: &V) -> bool
fn contains_value(&self, value: &V) -> bool
Returns true if this map contains a given value. False otherwise.
source§fn get<'a>(&'a self, key: &'a K) -> Option<&'a V>
fn get<'a>(&'a self, key: &'a K) -> Option<&'a V>
Gets a reference with the associated key. Will return None if that i
key is not in the map.
source§fn get_mut<'a>(&'a mut self, key: &'a K) -> Option<&'a mut V>
fn get_mut<'a>(&'a mut self, key: &'a K) -> Option<&'a mut V>
Gets a mutable reference with the associated key. Will return None if that
key is not in the map.
source§fn nth_value<'a>(&'a self, index: usize) -> Option<&'a V>where
K: 'a,
fn nth_value<'a>(&'a self, index: usize) -> Option<&'a V>where
K: 'a,
Gets a reference to the nth value in the map.
Will return None if index is out of bounds.
source§fn nth_value_mut<'a>(&'a mut self, index: usize) -> Option<&'a mut V>where
K: 'a,
fn nth_value_mut<'a>(&'a mut self, index: usize) -> Option<&'a mut V>where
K: 'a,
Gets a reference to the nth value in the map.
Will return None if index is out of bounds.
source§fn nth_key<'a>(&'a self, index: usize) -> Option<&'a K>where
V: 'a,
fn nth_key<'a>(&'a self, index: usize) -> Option<&'a K>where
V: 'a,
Gets a reference to the nth value in the map.
Will return None if index is out of bounds.
Auto Trait Implementations§
impl<K, V> Freeze for VecMap<K, V>
impl<K, V> RefUnwindSafe for VecMap<K, V>where
K: RefUnwindSafe,
V: RefUnwindSafe,
impl<K, V> Send for VecMap<K, V>
impl<K, V> Sync for VecMap<K, V>
impl<K, V> Unpin for VecMap<K, V>
impl<K, V> UnwindSafe for VecMap<K, V>where
K: UnwindSafe,
V: UnwindSafe,
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