pub struct LinearMap<K, V>(/* private fields */);
Expand description
O(n) Vec-backed map for keys that only implement Eq. Only use this for a very small number of keys, operations on it can easily become O(n^2).
Implementations§
Source§impl<K: Eq, V> LinearMap<K, V>
impl<K: Eq, V> LinearMap<K, V>
pub fn new() -> Self
pub fn get(&self, k: &K) -> Option<&V>
pub fn get_mut(&mut self, k: &K) -> Option<&mut V>
Sourcepub fn insert(&mut self, k: K, v: V) -> Option<V>
pub fn insert(&mut self, k: K, v: V) -> Option<V>
This is O(n), because we check for an existing entry.
pub fn get_or_insert_with(&mut self, k: K, f: impl FnOnce() -> V) -> &mut V
pub fn values(&self) -> impl Iterator<Item = &V>
Trait Implementations§
Source§impl<K: Eq, V> FromIterator<(K, V)> for LinearMap<K, V>
impl<K: Eq, V> FromIterator<(K, V)> for LinearMap<K, V>
Source§fn from_iter<T: IntoIterator<Item = (K, V)>>(iter: T) -> Self
fn from_iter<T: IntoIterator<Item = (K, V)>>(iter: T) -> Self
This calls insert
in a loop, so is O(n^2)!!
Source§impl<K, V> IntoIterator for LinearMap<K, V>
impl<K, V> IntoIterator for LinearMap<K, V>
Auto Trait Implementations§
impl<K, V> Freeze for LinearMap<K, V>
impl<K, V> RefUnwindSafe for LinearMap<K, V>where
K: RefUnwindSafe,
V: RefUnwindSafe,
impl<K, V> Send for LinearMap<K, V>
impl<K, V> Sync for LinearMap<K, V>
impl<K, V> Unpin for LinearMap<K, V>
impl<K, V> UnwindSafe for LinearMap<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