Struct indexmap::map::core::IndexMapCore

source ·
pub(crate) struct IndexMapCore<K, V> {
    indices: RawTable<usize>,
    entries: Vec<Bucket<K, V>>,
}
Expand description

Core of the map that does not depend on S

Fields§

§indices: RawTable<usize>

indices mapping from the entry hash to its index.

§entries: Vec<Bucket<K, V>>

entries is a dense vec of entries in their order.

Implementations§

source§

impl<K, V> IndexMapCore<K, V>

source

pub(crate) fn entry(&mut self, hash: HashValue, key: K) -> Entry<'_, K, V>
where K: Eq,

source§

impl<K, V> IndexMapCore<K, V>

source

pub(super) fn erase_indices_sweep(&mut self, start: usize, end: usize)

Sweep the whole table to erase indices start..end

source

pub(crate) fn find_or_insert( &mut self, hash: HashValue, key: &K, ) -> Result<usize, usize>
where K: Eq,

Search for a key in the table and return Ok(entry_index) if found. Otherwise, insert the key and return Err(new_index).

Note that hashbrown may resize the table to reserve space for insertion, even before checking if it’s already present, so this is somewhat biased towards new items.

source

pub(super) fn raw_entry( &mut self, hash: HashValue, is_match: impl FnMut(&K) -> bool, ) -> Result<RawTableEntry<'_, K, V>, &mut Self>

source

pub(super) fn index_raw_entry( &mut self, index: usize, ) -> Option<RawTableEntry<'_, K, V>>

source

pub(super) fn indices_mut(&mut self) -> impl Iterator<Item = &mut usize>

source§

impl<K, V> IndexMapCore<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 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

fn reserve_entries(&mut self, additional: usize)

Reserve entries capacity, rounded up to match the indices

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

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

fn insert_entry(&mut self, index: usize, hash: HashValue, key: K, value: V)

Insert a key-value pair in entries at a particular index, without checking whether it already exists.

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

fn insert_unique(&mut self, hash: HashValue, key: K, value: V) -> usize

source

fn shift_insert_unique( &mut self, index: usize, hash: HashValue, key: K, value: V, )

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

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(super) fn move_index(&mut self, from: usize, to: usize)

source

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

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

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

Trait Implementations§

source§

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

source§

fn clone(&self) -> Self

Returns a copy of the value. Read more
source§

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

Performs copy-assignment from source. Read more
source§

impl<K, V> Entries for IndexMapCore<K, V>

§

type Entry = Bucket<K, V>

source§

fn into_entries(self) -> Vec<Self::Entry>

source§

fn as_entries(&self) -> &[Self::Entry]

source§

fn as_entries_mut(&mut self) -> &mut [Self::Entry]

source§

fn with_entries<F>(&mut self, f: F)
where F: FnOnce(&mut [Self::Entry]),

Auto Trait Implementations§

§

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

§

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

§

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

§

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

§

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

§

impl<K, V> UnwindSafe for IndexMapCore<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> 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,

§

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

§

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

§

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.