Core

Struct Core 

Source
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>

Source

pub(crate) fn extract<R>(&mut self, range: R) -> ExtractCore<'_, K, V>
where R: RangeBounds<usize>,

Source§

impl<K, V> Core<K, V>

Source

const MAX_ENTRIES_CAPACITY: usize

The maximum capacity before the entries allocation would exceed isize::MAX.

Source

pub(crate) const fn new() -> Self

Source

pub(crate) fn with_capacity(n: usize) -> Self

Source

pub(crate) fn into_entries(self) -> Vec<Bucket<K, V>>

Source

pub(crate) fn as_entries(&self) -> &[Bucket<K, V>]

Source

pub(crate) fn as_entries_mut(&mut self) -> &mut [Bucket<K, V>]

Source

pub(crate) fn with_entries<F>(&mut self, f: F)
where F: FnOnce(&mut [Bucket<K, V>]),

Source

pub(crate) fn len(&self) -> usize

Source

pub(crate) fn capacity(&self) -> usize

Source

pub(crate) fn clear(&mut self)

Source

pub(crate) fn truncate(&mut self, len: usize)

Source

pub(crate) fn drain<R>(&mut self, range: R) -> Drain<'_, Bucket<K, V>>
where R: RangeBounds<usize>,

Source

pub(crate) fn split_off(&mut self, at: usize) -> Self

Source

pub(crate) fn split_splice<R>( &mut self, range: R, ) -> (Self, IntoIter<Bucket<K, V>>)
where R: RangeBounds<usize>,

Source

pub(crate) fn append_unchecked(&mut self, other: &mut Self)

Append from another map without checking whether items already exist.

Source

pub(crate) fn reserve(&mut self, additional: usize)

Reserve capacity for additional more key-value pairs.

Source

pub(crate) fn reserve_exact(&mut self, additional: usize)

Reserve capacity for additional more key-value pairs, without over-allocating.

Source

pub(crate) fn try_reserve( &mut self, additional: usize, ) -> Result<(), TryReserveError>

Try to reserve capacity for additional more key-value pairs.

Source

fn try_reserve_entries( &mut self, additional: usize, ) -> Result<(), TryReserveError>

Try to reserve entries capacity, rounded up to match the indices

Source

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.

Source

pub(crate) fn shrink_to(&mut self, min_capacity: usize)

Shrink the capacity of the map with a lower bound

Source

pub(crate) fn pop(&mut self) -> Option<(K, V)>

Remove the last key-value pair

Source

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

Source

pub(crate) fn get_index_of_raw<F>( &self, hash: HashValue, is_match: F, ) -> Option<usize>
where F: FnMut(&K) -> bool,

Return the index in entries where an equivalent key can be found

Source

fn push_entry(&mut self, hash: HashValue, key: K, value: V)

Append a key-value pair to entries, without checking whether it already exists.

Source

pub(crate) fn insert_full( &mut self, hash: HashValue, key: K, value: V, ) -> (usize, Option<V>)
where K: Eq,

Source

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

Source

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

Source

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

Source

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.

Source

pub(crate) fn retain_in_order<F>(&mut self, keep: F)
where F: FnMut(&mut K, &mut V) -> bool,

Source

fn rebuild_hash_table(&mut self)

Source

pub(crate) fn reverse(&mut self)

Source

fn reserve_entries(&mut self, additional: usize)

Reserve entries capacity, rounded up to match the indices

Source

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.

Source

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.

Source

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.

Source

pub(crate) fn shift_remove_index(&mut self, index: usize) -> Option<(K, V)>

Remove an entry by shifting all entries that follow it

Source

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.

Source

pub(crate) fn swap_remove_index(&mut self, index: usize) -> Option<(K, V)>

Remove an entry by swapping it with the last

Source

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.

Source

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.

Source

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.

Source

pub(crate) fn move_index(&mut self, from: usize, to: usize)

Source

fn move_index_inner(&mut self, from: usize, to: usize)

Source

pub(crate) fn swap_indices(&mut self, a: usize, b: usize)

Trait Implementations§

Source§

impl<K, V> Clone for Core<K, V>
where K: Clone, V: Clone,

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
Source§

fn clone_from(&mut self, other: &Self)

Performs copy-assignment from source. Read more

Auto Trait Implementations§

§

impl<K, V> Freeze for Core<K, V>

§

impl<K, V> RefUnwindSafe for Core<K, V>

§

impl<K, V> Send for Core<K, V>
where K: Send, V: Send,

§

impl<K, V> Sync for Core<K, V>
where K: Sync, V: Sync,

§

impl<K, V> Unpin for Core<K, V>
where K: Unpin, V: Unpin,

§

impl<K, V> UnwindSafe for Core<K, V>
where K: UnwindSafe, V: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.