indexmap::map::core

Struct IndexMapCore

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

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

const MAX_ENTRIES_CAPACITY: usize

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

Source

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

Source

fn borrow_mut(&mut self) -> RefMut<'_, K, V>

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

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

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 shift_remove_index(&mut self, index: usize) -> Option<(K, V)>

Remove an entry by shifting all entries that follow it

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 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: Debug, V: Debug> Debug for IndexMapCore<K, V>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

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

Source§

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> CloneToUninit for T
where T: Clone,

Source§

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

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. 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.