Struct std::collections::hash_map::raw_table::RawTable [] [src]

pub struct RawTable<K, V> {
    capacity: usize,
    size: usize,
    hashes: Unique<u64>,
    marker: PhantomData<(K, V)>,
}

The raw hashtable, providing safe-ish access to the unzipped and highly optimized arrays of hashes, keys, and values.

This design uses less memory and is a lot faster than the naive Vec<Option<u64, K, V>>, because we don't pay for the overhead of an option on every element, and we get a generally more cache-aware design.

Essential invariants of this structure:

You can kind of think of this module/data structure as a safe wrapper around just the "table" part of the hashtable. It enforces some invariants at the type level and employs some performance trickery, but in general is just a tricked out Vec<Option<u64, K, V>>.

Fields

capacity
size
hashes
marker

Methods

impl<K, V> RawTable<K, V>

unsafe fn new_uninitialized(capacity: usize) -> RawTable<K, V>

Does not initialize the buckets. The caller should ensure they, at the very least, set every hash to EMPTY_BUCKET.

fn first_bucket_raw(&self) -> RawBucket<K, V>

fn new(capacity: usize) -> RawTable<K, V>

Creates a new raw table from a given capacity. All buckets are initially empty.

fn capacity(&self) -> usize

The hashtable's capacity, similar to a vector's.

fn size(&self) -> usize

The number of elements ever put in the hashtable, minus the number of elements ever taken.

fn raw_buckets(&self) -> RawBuckets<K, V>

fn iter(&self) -> Iter<K, V>

fn iter_mut(&mut self) -> IterMut<K, V>

fn into_iter(self) -> IntoIter<K, V>

fn drain(&mut self) -> Drain<K, V>

unsafe fn rev_move_buckets(&mut self) -> RevMoveBuckets<K, V>

Returns an iterator that copies out each entry. Used while the table is being dropped.

Trait Implementations

impl<K: Send, V: Send> Send for RawTable<K, V>

impl<K: Sync, V: Sync> Sync for RawTable<K, V>

impl<K: Clone, V: Clone> Clone for RawTable<K, V>

fn clone(&self) -> RawTable<K, V>

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

impl<K, V> Drop for RawTable<K, V>

fn drop(&mut self)