pub struct InlineSparseScalarLookupMap<K, V, const SZ: usize, const LTSZ: usize, CM = SmallCollection> { /* private fields */ }Expand description
A map whose keys are a sparse range of integers.
§Type Parameters
K: The key type.V: The value type.CM: The magnitude of the map, one ofSmallCollection,MediumCollection, orLargeCollection.SZ: The number of entries in the map.LTSZ: The number of entries in the lookup table.
Implementations§
Source§impl<K, V, const SZ: usize, const LTSZ: usize, CM> InlineSparseScalarLookupMap<K, V, SZ, LTSZ, CM>where
CM: CollectionMagnitude,
impl<K, V, const SZ: usize, const LTSZ: usize, CM> InlineSparseScalarLookupMap<K, V, SZ, LTSZ, CM>where
CM: CollectionMagnitude,
Sourcepub const fn new_raw(
sorted_and_dedupped_entries: [(K, V); SZ],
lookup: [CM; LTSZ],
min: usize,
max: usize,
) -> Self
pub const fn new_raw( sorted_and_dedupped_entries: [(K, V); SZ], lookup: [CM; LTSZ], min: usize, max: usize, ) -> Self
Sourcepub fn get<Q>(&self, key: &Q) -> Option<&V>where
Q: Comparable<K> + Scalar,
pub fn get<Q>(&self, key: &Q) -> Option<&V>where
Q: Comparable<K> + Scalar,
Returns a reference to the value corresponding to the key.
The key may be any borrowed form of the map’s key type.
Sourcepub fn get_mut<Q>(&mut self, key: &Q) -> Option<&mut V>where
Q: Comparable<K> + Scalar,
pub fn get_mut<Q>(&mut self, key: &Q) -> Option<&mut V>where
Q: Comparable<K> + Scalar,
Returns a mutable reference to the value corresponding to the key.
The key may be any borrowed form of the map’s key type.
Sourcepub fn get_key_value<Q>(&self, key: &Q) -> Option<(&K, &V)>where
Q: Comparable<K> + Scalar,
pub fn get_key_value<Q>(&self, key: &Q) -> Option<(&K, &V)>where
Q: Comparable<K> + Scalar,
Returns the key-value pair corresponding to the supplied key.
This is potentially useful:
-
for key types where non-identical keys can be considered equal;
-
for getting the &K stored key value from a borrowed &Q lookup key; or
-
for getting a reference to a key with the same lifetime as the collection.
-
The supplied key may be any borrowed form of the map’s key type, but Hash and Eq on the borrowed form must match those for the key type.
Sourcepub fn contains_key<Q>(&self, key: &Q) -> boolwhere
Q: Comparable<K> + Scalar,
pub fn contains_key<Q>(&self, key: &Q) -> boolwhere
Q: Comparable<K> + Scalar,
Returns true if the map contains a value for the specified key.
The key may be any borrowed form of the map’s key type.
Sourcepub fn get_disjoint_mut<Q, const N: usize>(
&mut self,
keys: [&Q; N],
) -> [Option<&mut V>; N]
pub fn get_disjoint_mut<Q, const N: usize>( &mut self, keys: [&Q; N], ) -> [Option<&mut V>; N]
Gets multiple mutable values from the map.
§Panics
Panics if the same key is specified multiple times.
Sourcepub unsafe fn get_disjoint_unchecked_mut<Q, const N: usize>(
&mut self,
keys: [&Q; N],
) -> [Option<&mut V>; N]where
Q: Comparable<K> + Scalar,
pub unsafe fn get_disjoint_unchecked_mut<Q, const N: usize>(
&mut self,
keys: [&Q; N],
) -> [Option<&mut V>; N]where
Q: Comparable<K> + Scalar,
Gets multiple mutable values from the map.
§Safety
Calling this method with overlapping keys is undefined behavior even if the resulting references are not used.
Sourcepub fn iter_mut(&mut self) -> IterMut<'_, K, V> ⓘ
pub fn iter_mut(&mut self) -> IterMut<'_, K, V> ⓘ
An iterator producing mutable references to all entries in arbitrary order.
Sourcepub fn into_keys(self) -> IntoKeys<K, V> ⓘ
pub fn into_keys(self) -> IntoKeys<K, V> ⓘ
A consuming iterator visiting all keys in arbitrary order.
Sourcepub fn values_mut(&mut self) -> ValuesMut<'_, K, V> ⓘ
pub fn values_mut(&mut self) -> ValuesMut<'_, K, V> ⓘ
An iterator visiting all values mutably in arbitrary order.
Sourcepub fn into_values(self) -> IntoValues<K, V> ⓘ
pub fn into_values(self) -> IntoValues<K, V> ⓘ
A consuming iterator visiting all values in arbitrary order.
Trait Implementations§
Source§impl<K: Clone, V: Clone, const SZ: usize, const LTSZ: usize, CM: Clone> Clone for InlineSparseScalarLookupMap<K, V, SZ, LTSZ, CM>
impl<K: Clone, V: Clone, const SZ: usize, const LTSZ: usize, CM: Clone> Clone for InlineSparseScalarLookupMap<K, V, SZ, LTSZ, CM>
Source§fn clone(&self) -> InlineSparseScalarLookupMap<K, V, SZ, LTSZ, CM>
fn clone(&self) -> InlineSparseScalarLookupMap<K, V, SZ, LTSZ, CM>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl<K, V, const SZ: usize, const LTSZ: usize, CM> Debug for InlineSparseScalarLookupMap<K, V, SZ, LTSZ, CM>
impl<K, V, const SZ: usize, const LTSZ: usize, CM> Debug for InlineSparseScalarLookupMap<K, V, SZ, LTSZ, CM>
Source§impl<K, V, Q, const SZ: usize, const LTSZ: usize, CM> Index<&Q> for InlineSparseScalarLookupMap<K, V, SZ, LTSZ, CM>
impl<K, V, Q, const SZ: usize, const LTSZ: usize, CM> Index<&Q> for InlineSparseScalarLookupMap<K, V, SZ, LTSZ, CM>
Source§impl<'a, K, V, const SZ: usize, const LTSZ: usize, CM> IntoIterator for &'a InlineSparseScalarLookupMap<K, V, SZ, LTSZ, CM>where
CM: CollectionMagnitude,
impl<'a, K, V, const SZ: usize, const LTSZ: usize, CM> IntoIterator for &'a InlineSparseScalarLookupMap<K, V, SZ, LTSZ, CM>where
CM: CollectionMagnitude,
Source§impl<'a, K, V, const SZ: usize, const LTSZ: usize, CM> IntoIterator for &'a mut InlineSparseScalarLookupMap<K, V, SZ, LTSZ, CM>where
CM: CollectionMagnitude,
impl<'a, K, V, const SZ: usize, const LTSZ: usize, CM> IntoIterator for &'a mut InlineSparseScalarLookupMap<K, V, SZ, LTSZ, CM>where
CM: CollectionMagnitude,
Source§impl<K, V, const SZ: usize, const LTSZ: usize, CM> IntoIterator for InlineSparseScalarLookupMap<K, V, SZ, LTSZ, CM>where
CM: CollectionMagnitude,
impl<K, V, const SZ: usize, const LTSZ: usize, CM> IntoIterator for InlineSparseScalarLookupMap<K, V, SZ, LTSZ, CM>where
CM: CollectionMagnitude,
Source§impl<K, V, const SZ: usize, const LTSZ: usize, CM> Len for InlineSparseScalarLookupMap<K, V, SZ, LTSZ, CM>where
CM: CollectionMagnitude,
impl<K, V, const SZ: usize, const LTSZ: usize, CM> Len for InlineSparseScalarLookupMap<K, V, SZ, LTSZ, CM>where
CM: CollectionMagnitude,
Source§impl<K, V, Q, const SZ: usize, const LTSZ: usize, CM> MapExtras<K, V, Q> for InlineSparseScalarLookupMap<K, V, SZ, LTSZ, CM>
impl<K, V, Q, const SZ: usize, const LTSZ: usize, CM> MapExtras<K, V, Q> for InlineSparseScalarLookupMap<K, V, SZ, LTSZ, CM>
Source§impl<K, V, const SZ: usize, const LTSZ: usize, CM> MapIteration<K, V> for InlineSparseScalarLookupMap<K, V, SZ, LTSZ, CM>where
CM: CollectionMagnitude,
impl<K, V, const SZ: usize, const LTSZ: usize, CM> MapIteration<K, V> for InlineSparseScalarLookupMap<K, V, SZ, LTSZ, CM>where
CM: CollectionMagnitude,
Source§type Iterator<'a> = Iter<'a, K, V>
where
K: 'a,
V: 'a,
CM: 'a
type Iterator<'a> = Iter<'a, K, V> where K: 'a, V: 'a, CM: 'a
Self::iter.Source§type KeyIterator<'a> = Keys<'a, K, V>
where
K: 'a,
V: 'a,
CM: 'a
type KeyIterator<'a> = Keys<'a, K, V> where K: 'a, V: 'a, CM: 'a
Self::keys.Source§type ValueIterator<'a> = Values<'a, K, V>
where
K: 'a,
V: 'a,
CM: 'a
type ValueIterator<'a> = Values<'a, K, V> where K: 'a, V: 'a, CM: 'a
Self::values.Source§type MutIterator<'a> = IterMut<'a, K, V>
where
K: 'a,
V: 'a,
CM: 'a
type MutIterator<'a> = IterMut<'a, K, V> where K: 'a, V: 'a, CM: 'a
Self::iter_mut.Source§type ValueMutIterator<'a> = ValuesMut<'a, K, V>
where
K: 'a,
V: 'a,
CM: 'a
type ValueMutIterator<'a> = ValuesMut<'a, K, V> where K: 'a, V: 'a, CM: 'a
Self::values_mut.Source§type IntoKeyIterator = IntoKeys<K, V>
type IntoKeyIterator = IntoKeys<K, V>
Self::into_keys.Source§type IntoValueIterator = IntoValues<K, V>
type IntoValueIterator = IntoValues<K, V>
Self::into_values.Source§fn iter_mut(&mut self) -> Self::MutIterator<'_>
fn iter_mut(&mut self) -> Self::MutIterator<'_>
Source§fn keys(&self) -> Self::KeyIterator<'_>
fn keys(&self) -> Self::KeyIterator<'_>
Source§fn into_keys(self) -> Self::IntoKeyIterator
fn into_keys(self) -> Self::IntoKeyIterator
Source§fn values(&self) -> Self::ValueIterator<'_>
fn values(&self) -> Self::ValueIterator<'_>
Source§fn values_mut(&mut self) -> Self::ValueMutIterator<'_>
fn values_mut(&mut self) -> Self::ValueMutIterator<'_>
Source§fn into_values(self) -> Self::IntoValueIterator
fn into_values(self) -> Self::IntoValueIterator
Source§impl<K, V, Q, const SZ: usize, const LTSZ: usize, CM> MapQuery<Q, V> for InlineSparseScalarLookupMap<K, V, SZ, LTSZ, CM>
impl<K, V, Q, const SZ: usize, const LTSZ: usize, CM> MapQuery<Q, V> for InlineSparseScalarLookupMap<K, V, SZ, LTSZ, CM>
Source§impl<K, V, MT, const SZ: usize, const LTSZ: usize, CM> PartialEq<MT> for InlineSparseScalarLookupMap<K, V, SZ, LTSZ, CM>
impl<K, V, MT, const SZ: usize, const LTSZ: usize, CM> PartialEq<MT> for InlineSparseScalarLookupMap<K, V, SZ, LTSZ, CM>
Source§impl<K, V, const SZ: usize, const LTSZ: usize, CM> Serialize for InlineSparseScalarLookupMap<K, V, SZ, LTSZ, CM>
Available on crate feature serde only.
impl<K, V, const SZ: usize, const LTSZ: usize, CM> Serialize for InlineSparseScalarLookupMap<K, V, SZ, LTSZ, CM>
serde only.impl<K, V, const SZ: usize, const LTSZ: usize, CM> Eq for InlineSparseScalarLookupMap<K, V, SZ, LTSZ, CM>
impl<K, V, Q, const SZ: usize, const LTSZ: usize, CM> Map<K, V, Q> for InlineSparseScalarLookupMap<K, V, SZ, LTSZ, CM>
Auto Trait Implementations§
impl<K, V, const SZ: usize, const LTSZ: usize, CM> Freeze for InlineSparseScalarLookupMap<K, V, SZ, LTSZ, CM>
impl<K, V, const SZ: usize, const LTSZ: usize, CM> RefUnwindSafe for InlineSparseScalarLookupMap<K, V, SZ, LTSZ, CM>
impl<K, V, const SZ: usize, const LTSZ: usize, CM> Send for InlineSparseScalarLookupMap<K, V, SZ, LTSZ, CM>
impl<K, V, const SZ: usize, const LTSZ: usize, CM> Sync for InlineSparseScalarLookupMap<K, V, SZ, LTSZ, CM>
impl<K, V, const SZ: usize, const LTSZ: usize, CM> Unpin for InlineSparseScalarLookupMap<K, V, SZ, LTSZ, CM>
impl<K, V, const SZ: usize, const LTSZ: usize, CM> UnsafeUnpin for InlineSparseScalarLookupMap<K, V, SZ, LTSZ, CM>
impl<K, V, const SZ: usize, const LTSZ: usize, CM> UnwindSafe for InlineSparseScalarLookupMap<K, V, SZ, LTSZ, CM>
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.