[−][src]Struct griddle::raw::RawTable
A raw hash table with an unsafe API.
This is a wrapper around hashbrown::raw::RawTable
that also implements incremental
resizing. When you interact with this API, keep in mind that there may be two backing tables,
and a lookup may return a reference to either. Eventually, entries in the old table will be
reclaimed, which invalidates any references to them.
Implementations
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(&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 so that it fits as close to min_size
elements as possible.
In reality, the table may end up larger than min_size
, as must be able to hold all the
current elements, as well as some additional elements due to incremental resizing.
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.
While we try to make this incremental where possible, it may require all-at-once resizing.
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.
While we try to make this incremental where possible, it may require all-at-once resizing.
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.
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.
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.
impl<T: Clone> RawTable<T>
[src]
pub fn clone_from_with_hasher(
&mut self,
source: &Self,
hasher: impl Fn(&T) -> u64
)
[src]
&mut self,
source: &Self,
hasher: impl Fn(&T) -> u64
)
Variant of clone_from
to use when a hasher is available.
impl<T> RawTable<T>
[src]
pub unsafe fn par_iter(&self) -> RawParIter<T>
[src]
Returns a parallel iterator over the elements in a RawTable
.
Trait Implementations
impl<T: Clone> Clone 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>
[src]
Auto Trait Implementations
impl<T> RefUnwindSafe for RawTable<T> where
T: RefUnwindSafe,
T: RefUnwindSafe,
impl<T> Send for RawTable<T> where
T: Send,
T: Send,
impl<T> Sync for RawTable<T> where
T: Sync,
T: Sync,
impl<T> Unpin for RawTable<T> where
T: Unpin,
T: Unpin,
impl<T> UnwindSafe for RawTable<T> where
T: RefUnwindSafe + UnwindSafe,
T: RefUnwindSafe + UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<I> IntoIterator for I where
I: Iterator,
[src]
I: Iterator,
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?
fn into_iter(self) -> I
[src]
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,