Struct hashbrown::raw::RawTable [−][src]
pub struct RawTable<T, A: Allocator + Clone = Global> { /* fields omitted */ }
Expand description
A raw hash table with an unsafe API.
Implementations
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.
Attempts to allocate a new hash table with at least enough capacity for inserting the given number of elements without reallocating.
Allocates a new hash table with at least enough capacity for inserting the given number of elements without reallocating.
Creates a new empty hash table without allocating any memory, using the given allocator.
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.
Attempts to allocate a new hash table using the given allocator, with at least enough capacity for inserting the given number of elements without reallocating.
Allocates a new hash table using the given allocator, with at least enough capacity for inserting the given number of elements without reallocating.
Returns pointer to one past last element of data table.
Returns the index of a bucket from a Bucket
.
Returns a pointer to an element in the table.
👎 Deprecated since 0.8.1: use erase or remove instead
use erase or remove instead
Erases an element from the table without dropping it.
Erases an element from the table, dropping it in place.
Finds and erases an element from the table, dropping it in place. Returns true if an element was found.
Removes an element from the table, returning it.
Finds and removes an element from the table, returning it.
Marks all table buckets as empty without dropping their contents.
Shrinks the table to fit max(self.len(), min_size)
elements.
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<(), TryReserveError>
pub fn try_reserve(
&mut self,
additional: usize,
hasher: impl Fn(&T) -> u64
) -> Result<(), TryReserveError>
Tries to ensure that at least additional
items can be inserted into
the table without reallocation.
Inserts a new element into the table, and returns its raw bucket.
This does not check if the given element already exists in the table.
Attempts to insert a new element without growing the table and return its raw bucket.
Returns an Err
containing the given element if inserting it would require growing the
table.
This does not check if the given element already exists in the table.
Inserts a new element into the table, and returns a mutable reference to it.
This does not check if the given element already exists in the table.
Inserts a new element into the table, without growing the table.
There must be enough space in the table to insert the new element.
This does not check if the given element already exists in the table.
Temporary removes a bucket, applying the given function to the removed element and optionally put back the returned value in the same bucket.
Returns true
if the bucket still contains an element
This does not check if the given bucket is actually occupied.
Searches for an element in the table.
Gets a reference to an element in the table.
Gets a mutable reference to an element in the table.
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.
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.
pub unsafe fn iter_hash(&self, hash: u64) -> RawIterHash<'_, T, A>ⓘNotable traits for RawIterHash<'a, T, A>impl<'a, T, A: Allocator + Clone> Iterator for RawIterHash<'a, T, A> type Item = Bucket<T>;
pub unsafe fn iter_hash(&self, hash: u64) -> RawIterHash<'_, T, A>ⓘNotable traits for RawIterHash<'a, T, A>impl<'a, T, A: Allocator + Clone> Iterator for RawIterHash<'a, T, A> type Item = Bucket<T>;
impl<'a, T, A: Allocator + Clone> Iterator for RawIterHash<'a, T, A> type Item = Bucket<T>;
Returns an iterator over occupied buckets that could match a given hash.
In rare cases, the iterator may return a bucket with a different hash.
It is up to the caller to ensure that the RawTable
outlives the
RawIterHash
. Because we cannot make the next
method unsafe on the
RawIterHash
struct, we have to make the iter_hash
method unsafe.
Returns an iterator which removes all elements from the table without freeing the memory.
Returns an iterator which removes all elements from the table without freeing the memory.
Iteration starts at the provided iterator’s current location.
It is up to the caller to ensure that the iterator is valid for this
RawTable
and covers all items that remain in the table.
pub unsafe fn into_iter_from(self, iter: RawIter<T>) -> RawIntoIter<T, A>ⓘNotable traits for RawIntoIter<T, A>impl<T, A: Allocator + Clone> Iterator for RawIntoIter<T, A> type Item = T;
pub unsafe fn into_iter_from(self, iter: RawIter<T>) -> RawIntoIter<T, A>ⓘNotable traits for RawIntoIter<T, A>impl<T, A: Allocator + Clone> Iterator for RawIntoIter<T, A> type Item = T;
impl<T, A: Allocator + Clone> Iterator for RawIntoIter<T, A> type Item = T;
Returns an iterator which consumes all elements from the table.
Iteration starts at the provided iterator’s current location.
It is up to the caller to ensure that the iterator is valid for this
RawTable
and covers all items that remain in the table.
Trait Implementations
type Item = T
type Item = T
The type of the elements being iterated over.
type IntoIter = RawIntoIter<T, A>
type IntoIter = RawIntoIter<T, A>
Which kind of iterator are we turning this into?
fn into_iter(self) -> RawIntoIter<T, A>ⓘNotable traits for RawIntoIter<T, A>impl<T, A: Allocator + Clone> Iterator for RawIntoIter<T, A> type Item = T;
fn into_iter(self) -> RawIntoIter<T, A>ⓘNotable traits for RawIntoIter<T, A>impl<T, A: Allocator + Clone> Iterator for RawIntoIter<T, A> type Item = T;
impl<T, A: Allocator + Clone> Iterator for RawIntoIter<T, A> type Item = T;
Creates an iterator from a value. Read more
Auto Trait Implementations
impl<T, A> RefUnwindSafe for RawTable<T, A> where
A: RefUnwindSafe,
T: RefUnwindSafe,
impl<T, A> UnwindSafe for RawTable<T, A> where
A: UnwindSafe,
T: UnwindSafe,
Blanket Implementations
Mutably borrows from an owned value. Read more