pub(crate) struct Core<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> Core<K, V>
impl<K, V> Core<K, V>
pub(crate) fn extract<R>(&mut self, range: R) -> ExtractCore<'_, K, V>where
R: RangeBounds<usize>,
Source§impl<K, V> Core<K, V>
impl<K, V> Core<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
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
Sourcepub(crate) fn get_index_of_raw<F>(
&self,
hash: HashValue,
is_match: F,
) -> Option<usize>
pub(crate) fn get_index_of_raw<F>( &self, hash: HashValue, is_match: F, ) -> Option<usize>
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 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 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
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.
pub(crate) fn retain_in_order<F>(&mut self, keep: F)
fn rebuild_hash_table(&mut self)
pub(crate) fn reverse(&mut self)
Sourcefn reserve_entries(&mut self, additional: usize)
fn reserve_entries(&mut self, additional: usize)
Reserve entries capacity, rounded up to match the indices
Sourcepub(crate) fn insert_unique(
&mut self,
hash: HashValue,
key: K,
value: V,
) -> &mut Bucket<K, V>
pub(crate) fn insert_unique( &mut self, hash: HashValue, key: K, value: V, ) -> &mut Bucket<K, V>
Insert a key-value pair in entries,
without checking whether it already exists.
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_insert_unique(
&mut self,
index: usize,
hash: HashValue,
key: K,
value: V,
) -> &mut Bucket<K, V>
pub(crate) fn shift_insert_unique( &mut self, index: usize, hash: HashValue, key: K, value: V, ) -> &mut Bucket<K, V>
Insert a key-value pair in entries at a particular index,
without checking whether it already exists.
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
Sourcefn shift_remove_finish(&mut self, index: usize) -> (K, V)
fn shift_remove_finish(&mut self, index: usize) -> (K, V)
Remove an entry by shifting all entries that follow it
The index should already be removed from self.indices.
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 swap_remove_finish(&mut self, index: usize) -> (K, V)
fn swap_remove_finish(&mut self, index: usize) -> (K, V)
Finish removing an entry by swapping it with the last
The index should already be removed from self.indices.
Sourcefn decrement_indices(&mut self, start: usize, end: usize)
fn decrement_indices(&mut self, start: usize, end: usize)
Decrement all indices in the range start..end.
The index start - 1 should not exist in self.indices.
All entries should still be in their original positions.
Sourcefn increment_indices(&mut self, start: usize, end: usize)
fn increment_indices(&mut self, start: usize, end: usize)
Increment all indices in the range start..end.
The index end should not exist in self.indices.
All entries should still be in their original positions.