pub(crate) struct IndexMapCore<K, V> {
indices: HashTable<usize>,
entries: Vec<Bucket<K, V>>,
}Expand description
Core of the map that does not depend on S
Fields§
§indices: HashTable<usize>indices mapping from the entry hash to its index.
entries: Vec<Bucket<K, V>>entries is a dense vec maintaining entry order.
Implementations§
Source§impl<K, V> IndexMapCore<K, V>
impl<K, V> IndexMapCore<K, V>
Source§impl<K, V> IndexMapCore<K, V>
impl<K, V> IndexMapCore<K, V>
pub(crate) fn extract<R>(&mut self, range: R) -> ExtractCore<'_, K, V>where
R: RangeBounds<usize>,
Source§impl<K, V> IndexMapCore<K, V>
impl<K, V> IndexMapCore<K, V>
Sourceconst MAX_ENTRIES_CAPACITY: usize
const MAX_ENTRIES_CAPACITY: usize
The maximum capacity before the entries allocation would exceed isize::MAX.
pub(crate) const fn new() -> Self
fn borrow_mut(&mut self) -> RefMut<'_, K, V>
pub(crate) fn with_capacity(n: usize) -> Self
pub(crate) fn into_entries(self) -> Vec<Bucket<K, V>>
pub(crate) fn as_entries(&self) -> &[Bucket<K, V>]
pub(crate) fn as_entries_mut(&mut self) -> &mut [Bucket<K, V>]
pub(crate) fn with_entries<F>(&mut self, f: F)
pub(crate) fn len(&self) -> usize
pub(crate) fn capacity(&self) -> usize
pub(crate) fn clear(&mut self)
pub(crate) fn truncate(&mut self, len: usize)
pub(crate) fn drain<R>(&mut self, range: R) -> Drain<'_, Bucket<K, V>>where
R: RangeBounds<usize>,
pub(crate) fn split_off(&mut self, at: usize) -> Self
pub(crate) fn split_splice<R>(
&mut self,
range: R,
) -> (Self, IntoIter<Bucket<K, V>>)where
R: RangeBounds<usize>,
Sourcepub(crate) fn append_unchecked(&mut self, other: &mut Self)
pub(crate) fn append_unchecked(&mut self, other: &mut Self)
Append from another map without checking whether items already exist.
Sourcepub(crate) fn reserve(&mut self, additional: usize)
pub(crate) fn reserve(&mut self, additional: usize)
Reserve capacity for additional more key-value pairs.
Sourcepub(crate) fn reserve_exact(&mut self, additional: usize)
pub(crate) fn reserve_exact(&mut self, additional: usize)
Reserve capacity for additional more key-value pairs, without over-allocating.
Sourcepub(crate) fn try_reserve(
&mut self,
additional: usize,
) -> Result<(), TryReserveError>
pub(crate) fn try_reserve( &mut self, additional: usize, ) -> Result<(), TryReserveError>
Try to reserve capacity for additional more key-value pairs.
Sourcefn try_reserve_entries(
&mut self,
additional: usize,
) -> Result<(), TryReserveError>
fn try_reserve_entries( &mut self, additional: usize, ) -> Result<(), TryReserveError>
Try to reserve entries capacity, rounded up to match the indices
Sourcepub(crate) fn try_reserve_exact(
&mut self,
additional: usize,
) -> Result<(), TryReserveError>
pub(crate) fn try_reserve_exact( &mut self, additional: usize, ) -> Result<(), TryReserveError>
Try to reserve capacity for additional more key-value pairs, without over-allocating.
Sourcepub(crate) fn shrink_to(&mut self, min_capacity: usize)
pub(crate) fn shrink_to(&mut self, min_capacity: usize)
Shrink the capacity of the map with a lower bound
Sourcepub(crate) fn get_index_of<Q>(&self, hash: HashValue, key: &Q) -> Option<usize>where
Q: ?Sized + Equivalent<K>,
pub(crate) fn get_index_of<Q>(&self, hash: HashValue, key: &Q) -> Option<usize>where
Q: ?Sized + Equivalent<K>,
Return the index in entries where an equivalent key can be found
Sourcefn push_entry(&mut self, hash: HashValue, key: K, value: V)
fn push_entry(&mut self, hash: HashValue, key: K, value: V)
Append a key-value pair to entries,
without checking whether it already exists.
pub(crate) fn insert_full(
&mut self,
hash: HashValue,
key: K,
value: V,
) -> (usize, Option<V>)where
K: Eq,
Sourcepub(crate) fn replace_full(
&mut self,
hash: HashValue,
key: K,
value: V,
) -> (usize, Option<(K, V)>)where
K: Eq,
pub(crate) fn replace_full(
&mut self,
hash: HashValue,
key: K,
value: V,
) -> (usize, Option<(K, V)>)where
K: Eq,
Same as insert_full, except it also replaces the key
Sourcepub(crate) fn replace_index_unique(
&mut self,
index: usize,
hash: HashValue,
key: K,
) -> K
pub(crate) fn replace_index_unique( &mut self, index: usize, hash: HashValue, key: K, ) -> K
Replaces the key at the given index, without checking whether it already exists.
Sourcepub(crate) fn shift_remove_full<Q>(
&mut self,
hash: HashValue,
key: &Q,
) -> Option<(usize, K, V)>where
Q: ?Sized + Equivalent<K>,
pub(crate) fn shift_remove_full<Q>(
&mut self,
hash: HashValue,
key: &Q,
) -> Option<(usize, K, V)>where
Q: ?Sized + Equivalent<K>,
Remove an entry by shifting all entries that follow it
Sourcepub(crate) fn shift_remove_index(&mut self, index: usize) -> Option<(K, V)>
pub(crate) fn shift_remove_index(&mut self, index: usize) -> Option<(K, V)>
Remove an entry by shifting all entries that follow it
pub(super) fn move_index(&mut self, from: usize, to: usize)
pub(crate) fn swap_indices(&mut self, a: usize, b: usize)
Sourcepub(crate) fn swap_remove_full<Q>(
&mut self,
hash: HashValue,
key: &Q,
) -> Option<(usize, K, V)>where
Q: ?Sized + Equivalent<K>,
pub(crate) fn swap_remove_full<Q>(
&mut self,
hash: HashValue,
key: &Q,
) -> Option<(usize, K, V)>where
Q: ?Sized + Equivalent<K>,
Remove an entry by swapping it with the last
Sourcepub(crate) fn swap_remove_index(&mut self, index: usize) -> Option<(K, V)>
pub(crate) fn swap_remove_index(&mut self, index: usize) -> Option<(K, V)>
Remove an entry by swapping it with the last
Sourcefn erase_indices(&mut self, start: usize, end: usize)
fn erase_indices(&mut self, start: usize, end: usize)
Erase start..end from indices, and shift end.. indices down to start..
All of these items should still be at their original location in entries.
This is used by drain, which will let Vec::drain do the work on entries.