#[repr(C)]pub struct SmallMap<K, V> { /* private fields */ }
Expand description
An memory-efficient key-value map with determinstic order.
Provides the standard container operations, modelled most closely on IndexMap
, plus:
-
Variants which take an already hashed value, e.g.
get_hashed
. -
Functions which work with the position, e.g.
get_index_of
.
Implementations
sourceimpl<K, V> SmallMap<K, V>
impl<K, V> SmallMap<K, V>
sourcepub fn with_capacity(n: usize) -> Self
pub fn with_capacity(n: usize) -> Self
Create an empty map with specified capacity.
sourcepub fn keys(&self) -> impl ExactSizeIterator<Item = &K> + Clone
pub fn keys(&self) -> impl ExactSizeIterator<Item = &K> + Clone
Key references iterator.
sourcepub fn values(&self) -> impl ExactSizeIterator<Item = &V> + Clone
pub fn values(&self) -> impl ExactSizeIterator<Item = &V> + Clone
Value references iterator.
sourcepub fn values_mut(&mut self) -> impl ExactSizeIterator<Item = &mut V>
pub fn values_mut(&mut self) -> impl ExactSizeIterator<Item = &mut V>
Mutable value references iterator.
sourcepub fn iter_hashed(
&self
) -> impl ExactSizeIterator<Item = (BorrowHashed<'_, K>, &V)>
pub fn iter_hashed(
&self
) -> impl ExactSizeIterator<Item = (BorrowHashed<'_, K>, &V)>
Entry references with hashes iterator.
sourcepub fn into_iter_hashed(self) -> impl ExactSizeIterator<Item = (Hashed<K>, V)>
pub fn into_iter_hashed(self) -> impl ExactSizeIterator<Item = (Hashed<K>, V)>
Entries with hashes iterator.
sourcepub fn into_iter(self) -> MHIntoIter<K, V>
pub fn into_iter(self) -> MHIntoIter<K, V>
Entries iterator.
sourcepub fn get_hashed<Q>(&self, key: BorrowHashed<'_, Q>) -> Option<&V> where
Q: Equivalent<K> + ?Sized,
K: Eq,
pub fn get_hashed<Q>(&self, key: BorrowHashed<'_, Q>) -> Option<&V> where
Q: Equivalent<K> + ?Sized,
K: Eq,
Query the map by a prehashed key.
sourcepub fn get<Q>(&self, key: &Q) -> Option<&V> where
Q: Hash + Equivalent<K> + ?Sized,
K: Eq,
pub fn get<Q>(&self, key: &Q) -> Option<&V> where
Q: Hash + Equivalent<K> + ?Sized,
K: Eq,
Query the map by a given key.
sourcepub fn get_full<Q>(&self, key: &Q) -> Option<(usize, &K, &V)> where
Q: Hash + Equivalent<K> + ?Sized,
K: Eq,
pub fn get_full<Q>(&self, key: &Q) -> Option<(usize, &K, &V)> where
Q: Hash + Equivalent<K> + ?Sized,
K: Eq,
Query the map by a given key, return an index of the entry along with the entry key and value.
sourcepub fn get_index_of_hashed<Q>(&self, key: BorrowHashed<'_, Q>) -> Option<usize> where
Q: Equivalent<K> + ?Sized,
K: Eq,
pub fn get_index_of_hashed<Q>(&self, key: BorrowHashed<'_, Q>) -> Option<usize> where
Q: Equivalent<K> + ?Sized,
K: Eq,
Find the index of the given hashed key.
sourcepub fn get_index_of<Q>(&self, key: &Q) -> Option<usize> where
Q: Hash + Equivalent<K> + ?Sized,
K: Eq,
pub fn get_index_of<Q>(&self, key: &Q) -> Option<usize> where
Q: Hash + Equivalent<K> + ?Sized,
K: Eq,
The an entry index by a given key.
sourcepub fn get_mut_hashed<Q>(&mut self, key: BorrowHashed<'_, Q>) -> Option<&mut V> where
Q: Equivalent<K> + ?Sized,
K: Eq,
pub fn get_mut_hashed<Q>(&mut self, key: BorrowHashed<'_, Q>) -> Option<&mut V> where
Q: Equivalent<K> + ?Sized,
K: Eq,
Find a mutable value by a hashed key.
sourcepub fn get_mut<Q>(&mut self, key: &Q) -> Option<&mut V> where
Q: Hash + Equivalent<K> + ?Sized,
K: Eq,
pub fn get_mut<Q>(&mut self, key: &Q) -> Option<&mut V> where
Q: Hash + Equivalent<K> + ?Sized,
K: Eq,
Find the entry by a given key.
sourcepub fn contains_key_hashed<Q>(&self, key: BorrowHashed<'_, Q>) -> bool where
Q: Equivalent<K> + ?Sized,
K: Eq,
pub fn contains_key_hashed<Q>(&self, key: BorrowHashed<'_, Q>) -> bool where
Q: Equivalent<K> + ?Sized,
K: Eq,
Find if an entry by a given prehashed key exists.
sourcepub fn contains_key<Q>(&self, key: &Q) -> bool where
Q: Hash + Equivalent<K> + ?Sized,
K: Eq,
pub fn contains_key<Q>(&self, key: &Q) -> bool where
Q: Hash + Equivalent<K> + ?Sized,
K: Eq,
Find if an entry by a given key exists.
sourcepub fn reserve(&mut self, additional: usize) where
K: Eq,
pub fn reserve(&mut self, additional: usize) where
K: Eq,
Reserve capacity for at least additional
more elements to be inserted.
sourcepub fn insert_hashed(&mut self, key: Hashed<K>, val: V) -> Option<V> where
K: Eq,
pub fn insert_hashed(&mut self, key: Hashed<K>, val: V) -> Option<V> where
K: Eq,
Insert a key-value pair into the map.
sourcepub fn insert(&mut self, key: K, val: V) -> Option<V> where
K: Hash + Eq,
pub fn insert(&mut self, key: K, val: V) -> Option<V> where
K: Hash + Eq,
Insert a key-value pair into the map.
sourcepub fn remove_hashed<Q>(&mut self, key: BorrowHashed<'_, Q>) -> Option<V> where
Q: ?Sized + Equivalent<K>,
K: Eq,
pub fn remove_hashed<Q>(&mut self, key: BorrowHashed<'_, Q>) -> Option<V> where
Q: ?Sized + Equivalent<K>,
K: Eq,
Remove the entry for the key.
This operation is linear in the number of entries in the map.
sourcepub fn remove_hashed_entry<Q>(
&mut self,
key: BorrowHashed<'_, Q>
) -> Option<(K, V)> where
Q: ?Sized + Equivalent<K>,
K: Eq,
pub fn remove_hashed_entry<Q>(
&mut self,
key: BorrowHashed<'_, Q>
) -> Option<(K, V)> where
Q: ?Sized + Equivalent<K>,
K: Eq,
Remove the entry for the key.
This operation is linear in the number of entries in the map.
sourcepub fn remove<Q>(&mut self, key: &Q) -> Option<V> where
Q: ?Sized + Hash + Equivalent<K>,
K: Eq,
pub fn remove<Q>(&mut self, key: &Q) -> Option<V> where
Q: ?Sized + Hash + Equivalent<K>,
K: Eq,
Remove the entry for the key.
sourcepub fn remove_entry<Q>(&mut self, key: &Q) -> Option<(K, V)> where
Q: ?Sized + Hash + Equivalent<K>,
K: Eq,
pub fn remove_entry<Q>(&mut self, key: &Q) -> Option<(K, V)> where
Q: ?Sized + Hash + Equivalent<K>,
K: Eq,
Remove the entry for the key.
sourcepub fn entry_hashed(&mut self, key: Hashed<K>) -> Entry<'_, K, V> where
K: Eq,
pub fn entry_hashed(&mut self, key: Hashed<K>) -> Entry<'_, K, V> where
K: Eq,
Get the entry (occupied or not) for the key.
Trait Implementations
sourceimpl<K, V> IntoIterator for SmallMap<K, V>
impl<K, V> IntoIterator for SmallMap<K, V>
sourceimpl<'a, K, V> IntoIterator for &'a SmallMap<K, V>
impl<'a, K, V> IntoIterator for &'a SmallMap<K, V>
sourceimpl<'a, K, V> IntoIterator for &'a mut SmallMap<K, V>
impl<'a, K, V> IntoIterator for &'a mut SmallMap<K, V>
sourceimpl<K: Ord, V: Ord> Ord for SmallMap<K, V>
impl<K: Ord, V: Ord> Ord for SmallMap<K, V>
sourceimpl<K: PartialOrd + Eq, V: PartialOrd> PartialOrd<SmallMap<K, V>> for SmallMap<K, V>
impl<K: PartialOrd + Eq, V: PartialOrd> PartialOrd<SmallMap<K, V>> for SmallMap<K, V>
sourcefn partial_cmp(&self, other: &Self) -> Option<Ordering>
fn partial_cmp(&self, other: &Self) -> Option<Ordering>
This method returns an ordering between self
and other
values if one exists. Read more
1.0.0 · sourcefn lt(&self, other: &Rhs) -> bool
fn lt(&self, other: &Rhs) -> bool
This method tests less than (for self
and other
) and is used by the <
operator. Read more
1.0.0 · sourcefn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
sourceimpl<'v, K: UnpackValue<'v> + Hash + Eq, V: UnpackValue<'v>> UnpackValue<'v> for SmallMap<K, V>
impl<'v, K: UnpackValue<'v> + Hash + Eq, V: UnpackValue<'v>> UnpackValue<'v> for SmallMap<K, V>
sourcefn unpack_value(value: Value<'v>) -> Option<Self>
fn unpack_value(value: Value<'v>) -> Option<Self>
sourcefn unpack_param(value: Value<'v>) -> Result<Self>
fn unpack_param(value: Value<'v>) -> Result<Self>
Unpack value, but instead of None
return error about incorrect argument type.
sourcefn unpack_named_param(value: Value<'v>, param_name: &str) -> Result<Self>
fn unpack_named_param(value: Value<'v>, param_name: &str) -> Result<Self>
Unpack value, but instead of None
return error about incorrect named argument type.
impl<FromK, FromV, ToK, ToV> Coerce<SmallMap<ToK, ToV>> for SmallMap<FromK, FromV> where
FromK: CoerceKey<ToK>,
FromV: Coerce<ToV>,
impl<K: Eq, V: Eq> Eq for SmallMap<K, V>
Auto Trait Implementations
impl<K, V> RefUnwindSafe for SmallMap<K, V> where
K: RefUnwindSafe,
V: RefUnwindSafe,
impl<K, V> Send for SmallMap<K, V> where
K: Send,
V: Send,
impl<K, V> Sync for SmallMap<K, V> where
K: Sync,
V: Sync,
impl<K, V> Unpin for SmallMap<K, V> where
K: Unpin,
V: Unpin,
impl<K, V> UnwindSafe for SmallMap<K, V> where
K: UnwindSafe,
V: UnwindSafe,
Blanket Implementations
sourceimpl<T> AsARef<T> for T where
T: ?Sized,
impl<T> AsARef<T> for T where
T: ?Sized,
sourcefn try_as_aref(this: &T) -> Result<ARef<'_, T>, BorrowError>
fn try_as_aref(this: &T) -> Result<ARef<'_, T>, BorrowError>
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
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
sourceimpl<Q, K> Equivalent<K> for Q where
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Q where
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
sourcefn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to key
and return true
if they are equal.
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more