Struct hashbrown::raw::RawTable [−][src]
pub struct RawTable<T> { /* fields omitted */ }
A raw hash table with an unsafe API.
Implementations
impl<T> RawTable<T>
[src]
impl<T> RawTable<T>
[src]pub const 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 try_with_capacity(capacity: usize) -> Result<Self, TryReserveError>
[src]
Attempts to allocate a new hash table with at least enough capacity for inserting the given number of elements without reallocating.
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 data_end(&self) -> NonNull<T>
[src]
Returns pointer to one past last element of data table.
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]
use erase or remove instead
Erases an element from the table without dropping it.
pub unsafe fn erase(&mut self, item: Bucket<T>)
[src]
Erases an element from the table, dropping it in place.
pub fn erase_entry(&mut self, hash: u64, eq: impl FnMut(&T) -> bool) -> bool
[src]
Finds and erases an element from the table, dropping it in place. Returns true if an element was found.
pub unsafe fn remove(&mut self, item: Bucket<T>) -> T
[src]
Removes an element from the table, returning it.
pub fn remove_entry(
&mut self,
hash: u64,
eq: impl FnMut(&T) -> bool
) -> Option<T>
[src]
&mut self,
hash: u64,
eq: impl FnMut(&T) -> bool
) -> Option<T>
Finds and removes an element from the table, returning 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<(), TryReserveError>
[src]
&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.
pub fn insert(
&mut self,
hash: u64,
value: T,
hasher: impl Fn(&T) -> u64
) -> Bucket<T>
[src]
&mut self,
hash: u64,
value: T,
hasher: impl Fn(&T) -> u64
) -> Bucket<T>
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.
pub fn insert_entry(
&mut self,
hash: u64,
value: T,
hasher: impl Fn(&T) -> u64
) -> &mut T
[src]
&mut self,
hash: u64,
value: T,
hasher: impl Fn(&T) -> u64
) -> &mut T
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.
pub fn insert_no_grow(&mut self, hash: u64, value: T) -> Bucket<T>
[src]
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.
pub unsafe fn replace_bucket_with<F>(&mut self, bucket: Bucket<T>, f: F) -> bool where
F: FnOnce(T) -> Option<T>,
[src]
F: FnOnce(T) -> Option<T>,
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.
pub fn find(&self, hash: u64, eq: impl FnMut(&T) -> bool) -> Option<Bucket<T>>
[src]
Searches for an element in the table.
pub fn get(&self, hash: u64, eq: impl FnMut(&T) -> bool) -> Option<&T>
[src]
Gets a reference to an element in the table.
pub fn get_mut(
&mut self,
hash: u64,
eq: impl FnMut(&T) -> bool
) -> Option<&mut T>
[src]
&mut self,
hash: u64,
eq: impl FnMut(&T) -> bool
) -> Option<&mut T>
Gets a mutable reference to 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.
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.
pub unsafe fn iter_hash(&self, hash: u64) -> RawIterHash<'_, T>ⓘNotable traits for RawIterHash<'a, T>
impl<'a, T> Iterator for RawIterHash<'a, T> type Item = Bucket<T>;
[src]
Notable traits for RawIterHash<'a, T>
impl<'a, T> Iterator for RawIterHash<'a, T> 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.
pub fn drain(&mut self) -> RawDrain<'_, T>ⓘ
[src]
Returns an iterator which removes all elements from the table without freeing the memory.
pub unsafe fn drain_iter_from(&mut self, iter: RawIter<T>) -> RawDrain<'_, T>ⓘ
[src]
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>ⓘNotable traits for RawIntoIter<T>
impl<T> Iterator for RawIntoIter<T> type Item = T;
[src]
Notable traits for RawIntoIter<T>
impl<T> Iterator for RawIntoIter<T> 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.
impl<T: Clone> RawTable<T>
[src]
impl<T: Clone> RawTable<T>
[src]impl<T> RawTable<T>
[src]
impl<T> RawTable<T>
[src]pub unsafe 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: Clone> Clone for RawTable<T>
[src]fn clone(&self) -> Self
[src]
fn clone_from(&mut self, source: &Self)
[src]
impl<T> IntoIterator 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?
fn into_iter(self) -> RawIntoIter<T>ⓘNotable traits for RawIntoIter<T>
impl<T> Iterator for RawIntoIter<T> type Item = T;
[src]
Notable traits for RawIntoIter<T>
impl<T> Iterator for RawIntoIter<T> type Item = T;
impl<T> Send for RawTable<T> where
T: Send,
[src]
T: Send,
impl<T> Sync for RawTable<T> where
T: Sync,
[src]
T: Sync,
Auto Trait Implementations
impl<T> RefUnwindSafe for RawTable<T> where
T: RefUnwindSafe,
T: RefUnwindSafe,
impl<T> Unpin for RawTable<T> where
T: Unpin,
T: Unpin,
impl<T> UnwindSafe for RawTable<T> where
T: UnwindSafe,
T: UnwindSafe,