[][src]Struct hashbrown::raw::RawTable

pub struct RawTable<T> { /* fields omitted */ }

A raw hash table with an unsafe API.

Methods

impl<T> RawTable<T>[src]

pub fn new() -> Self[src]

Creates a new empty hash table without allocating any memory.

In effect this returns a table with exactly 1 bucket. However we can leave the data pointer dangling since that bucket is never written to due to our load factor forcing us to always have at least 1 free bucket.

pub fn with_capacity(capacity: usize) -> Self[src]

Allocates a new hash table with at least enough capacity for inserting the given number of elements without reallocating.

pub unsafe fn bucket_index(&self, bucket: &Bucket<T>) -> usize[src]

Returns the index of a bucket from a Bucket.

pub unsafe fn bucket(&self, index: usize) -> Bucket<T>[src]

Returns a pointer to an element in the table.

pub unsafe fn erase_no_drop(&mut self, item: &Bucket<T>)[src]

Erases an element from the table without dropping it.

pub fn clear_no_drop(&mut self)[src]

Marks all table buckets as empty without dropping their contents.

pub fn clear(&mut self)[src]

Removes all elements from the table without freeing the backing memory.

pub fn shrink_to(&mut self, min_size: usize, hasher: impl Fn(&T) -> u64)[src]

Shrinks the table to fit max(self.len(), min_size) elements.

pub fn reserve(&mut self, additional: usize, hasher: impl Fn(&T) -> u64)[src]

Ensures that at least additional items can be inserted into the table without reallocation.

pub fn try_reserve(
    &mut self,
    additional: usize,
    hasher: impl Fn(&T) -> u64
) -> Result<(), CollectionAllocErr>
[src]

Tries to ensure that at least additional items can be inserted into the table without reallocation.

pub fn insert(
    &mut self,
    hash: u64,
    value: T,
    hasher: impl Fn(&T) -> u64
) -> Bucket<T>
[src]

Inserts a new element into the table.

This does not check if the given element already exists in the table.

pub fn find(&self, hash: u64, eq: impl FnMut(&T) -> bool) -> Option<Bucket<T>>[src]

Searches for an element in the table.

pub fn capacity(&self) -> usize[src]

Returns the number of elements the map can hold without reallocating.

This number is a lower bound; the table might be able to hold more, but is guaranteed to be able to hold at least this many.

pub fn len(&self) -> usize[src]

Returns the number of elements in the table.

pub fn buckets(&self) -> usize[src]

Returns the number of buckets in the table.

Important traits for RawIter<T>
pub unsafe fn iter(&self) -> RawIter<T>[src]

Returns an iterator over every element in the table. It is up to the caller to ensure that the RawTable outlives the RawIter. Because we cannot make the next method unsafe on the RawIter struct, we have to make the iter method unsafe.

Important traits for RawDrain<'_, T>
pub unsafe fn drain(&mut self) -> RawDrain<T>[src]

Returns an iterator which removes all elements from the table without freeing the memory. It is up to the caller to ensure that the RawTable outlives the RawDrain. Because we cannot make the next method unsafe on the RawDrain, we have to make the drain method unsafe.

impl<T> RawTable<T>[src]

pub fn par_iter(&self) -> RawParIter<T>[src]

Returns a parallel iterator over the elements in a RawTable.

pub fn into_par_iter(self) -> RawIntoParIter<T>[src]

Returns a parallel iterator over the elements in a RawTable.

pub fn par_drain(&mut self) -> RawParDrain<T>[src]

Returns a parallel iterator which consumes all elements of a RawTable without freeing its memory allocation.

Trait Implementations

impl<T: Clone> Clone for RawTable<T>[src]

impl<T> Drop for RawTable<T>[src]

impl<T> IntoIterator for RawTable<T>[src]

type Item = T

The type of the elements being iterated over.

type IntoIter = RawIntoIter<T>

Which kind of iterator are we turning this into?

impl<T> Send for RawTable<T> where
    T: Send
[src]

impl<T> Sync for RawTable<T> where
    T: Sync
[src]

Auto Trait Implementations

impl<T> RefUnwindSafe for RawTable<T> where
    T: RefUnwindSafe

impl<T> Unpin for RawTable<T> where
    T: Unpin

impl<T> UnwindSafe for RawTable<T> where
    T: RefUnwindSafe + UnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<I> IntoIterator for I where
    I: Iterator
[src]

type Item = <I as Iterator>::Item

The type of the elements being iterated over.

type IntoIter = I

Which kind of iterator are we turning this into?

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.