pub struct DefaultHashTable<TKey, TValue, TAllocator>{ /* private fields */ }Expand description
Represents the default hash table.
§Notes
At the moment it uses BytellHashTable as the underlying implementation.
This can change in the future though.
Implementations§
Source§impl<TKey, TValue, TAllocator> DefaultHashTable<TKey, TValue, TAllocator>
impl<TKey, TValue, TAllocator> DefaultHashTable<TKey, TValue, TAllocator>
Sourcepub fn new() -> Self
pub fn new() -> Self
Creates a new, empty DefaultHashTable with the default allocator.
Sourcepub fn with_allocator(allocator: TAllocator) -> Self
pub fn with_allocator(allocator: TAllocator) -> Self
Creates a new, empty DefaultHashTable with the specified allocator.
Sourcepub fn with_capacity(capacity: Length) -> Result<Self, DefaultHashTableError>
pub fn with_capacity(capacity: Length) -> Result<Self, DefaultHashTableError>
Creates a new DefaultHashTable with the specified capacity and the default allocator.
This likely will (over)allocate memory.
§Errors
See DefaultHashTableError for details.
Sourcepub fn with_capacity_and_allocator(
capacity: Length,
allocator: TAllocator,
) -> Result<Self, DefaultHashTableError>
pub fn with_capacity_and_allocator( capacity: Length, allocator: TAllocator, ) -> Result<Self, DefaultHashTableError>
Creates a new DefaultHashTable with the specified capacity and the specified allocator.
This likely will (over)allocate memory.
§Errors
See DefaultHashTableError for details.
Trait Implementations§
Source§impl<TKey, TValue: Clone, TAllocator> Clone for DefaultHashTable<TKey, TValue, TAllocator>
impl<TKey, TValue: Clone, TAllocator> Clone for DefaultHashTable<TKey, TValue, TAllocator>
Source§fn clone(&self) -> DefaultHashTable<TKey, TValue, TAllocator>
fn clone(&self) -> DefaultHashTable<TKey, TValue, TAllocator>
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl<TKey, TValue, TAllocator> Default for DefaultHashTable<TKey, TValue, TAllocator>
impl<TKey, TValue, TAllocator> Default for DefaultHashTable<TKey, TValue, TAllocator>
Source§impl<TKey, TValue: Hash, TAllocator> Hash for DefaultHashTable<TKey, TValue, TAllocator>
impl<TKey, TValue: Hash, TAllocator> Hash for DefaultHashTable<TKey, TValue, TAllocator>
Source§impl<TKey, TValue, TAllocator> ImmutableHashTable<TKey, TValue> for DefaultHashTable<TKey, TValue, TAllocator>
impl<TKey, TValue, TAllocator> ImmutableHashTable<TKey, TValue> for DefaultHashTable<TKey, TValue, TAllocator>
Source§fn length(&self) -> Length
fn length(&self) -> Length
Returns the number of
(TKey, TValue) pairs the table
contains. This typically does not correspond to the actual
size of the table in bytes.Source§fn contains<Q>(&self, key: &Q) -> bool
fn contains<Q>(&self, key: &Q) -> bool
Checks if the table contains the corresponding
key. Read moreSource§fn get<Q>(&self, key: &Q) -> Option<&TValue>
fn get<Q>(&self, key: &Q) -> Option<&TValue>
Checks if the table contains the corresponding
key, and if so then returns
the reference to the TValue, or None otherwise. Read moreSource§fn get_key_value<Q>(&self, key: &Q) -> Option<(&TKey, &TValue)>
fn get_key_value<Q>(&self, key: &Q) -> Option<(&TKey, &TValue)>
Checks if the table contains the corresponding
key, and if so then returns
the (&TKey, &TValue) pair or None otherwise. Read moreSource§impl<TKey, TValue, TAllocator> MutableHashTable<TKey, TValue> for DefaultHashTable<TKey, TValue, TAllocator>
impl<TKey, TValue, TAllocator> MutableHashTable<TKey, TValue> for DefaultHashTable<TKey, TValue, TAllocator>
Source§fn insert(&mut self, key: TKey, value: TValue) -> Option<TValue>
fn insert(&mut self, key: TKey, value: TValue) -> Option<TValue>
Inserts given
(TKey, TValue) pair into the table. Read moreSource§fn remove_entry<Q>(&mut self, key: &Q) -> Option<(TKey, TValue)>
fn remove_entry<Q>(&mut self, key: &Q) -> Option<(TKey, TValue)>
Removes entire entry from the table. Returns
(TKey, TValue) pair
for the matching key or None if there is no match. Read moreSource§fn insert_or_update_with<FAdd, FUpdate>(
&mut self,
key: TKey,
adder: FAdd,
updater: FUpdate,
) -> &mut TValue
fn insert_or_update_with<FAdd, FUpdate>( &mut self, key: TKey, adder: FAdd, updater: FUpdate, ) -> &mut TValue
Searches the table for a given
key. If the table contains it, then
it runs updater on the corresponding TValue. Otherwise runs adder
to add a new TValue to the table. Returns the mutable reference to the
final TValue. Read moreSource§fn iter_mut<'a>(
&'a mut self,
) -> impl Iterator<Item = (&'a TKey, &'a mut TValue)>where
TKey: 'a,
TValue: 'a,
Self: 'a,
fn iter_mut<'a>(
&'a mut self,
) -> impl Iterator<Item = (&'a TKey, &'a mut TValue)>where
TKey: 'a,
TValue: 'a,
Self: 'a,
Returns a mutable iterator over the key-value pairs in the table. Read more
Source§fn remove<Q>(&mut self, key: &Q) -> Option<TValue>
fn remove<Q>(&mut self, key: &Q) -> Option<TValue>
Removes entire entry from the table. Similar to
MutableHashTable::remove_entry,
but returns TValue only for the matching key or None if there is no match. Read moreSource§fn get_or_insert_default(&mut self, key: TKey) -> &mut TValuewhere
TValue: Default,
fn get_or_insert_default(&mut self, key: TKey) -> &mut TValuewhere
TValue: Default,
Retrieves an existing
TValue, or inserts a default one. Read moreSource§fn get_or_insert(&mut self, key: TKey, value: TValue) -> &mut TValue
fn get_or_insert(&mut self, key: TKey, value: TValue) -> &mut TValue
Retrieves an existing
TValue, or inserts the passed one. Read moreSource§impl<TKey, TValue: PartialEq, TAllocator> PartialEq for DefaultHashTable<TKey, TValue, TAllocator>
impl<TKey, TValue: PartialEq, TAllocator> PartialEq for DefaultHashTable<TKey, TValue, TAllocator>
Source§fn eq(&self, other: &DefaultHashTable<TKey, TValue, TAllocator>) -> bool
fn eq(&self, other: &DefaultHashTable<TKey, TValue, TAllocator>) -> bool
Tests for
self and other values to be equal, and is used by ==.Source§impl<TKey, TValue, TAllocator> ReprC for DefaultHashTable<TKey, TValue, TAllocator>
impl<TKey, TValue, TAllocator> ReprC for DefaultHashTable<TKey, TValue, TAllocator>
impl<TKey, TValue: Eq, TAllocator> Eq for DefaultHashTable<TKey, TValue, TAllocator>
impl<TKey, TValue, TAllocator> StructuralPartialEq for DefaultHashTable<TKey, TValue, TAllocator>
Auto Trait Implementations§
impl<TKey, TValue, TAllocator> Freeze for DefaultHashTable<TKey, TValue, TAllocator>where
TAllocator: Freeze,
impl<TKey, TValue, TAllocator> RefUnwindSafe for DefaultHashTable<TKey, TValue, TAllocator>
impl<TKey, TValue, TAllocator> Send for DefaultHashTable<TKey, TValue, TAllocator>
impl<TKey, TValue, TAllocator> Sync for DefaultHashTable<TKey, TValue, TAllocator>
impl<TKey, TValue, TAllocator> Unpin for DefaultHashTable<TKey, TValue, TAllocator>
impl<TKey, TValue, TAllocator> UnsafeUnpin for DefaultHashTable<TKey, TValue, TAllocator>where
TAllocator: UnsafeUnpin,
impl<TKey, TValue, TAllocator> UnwindSafe for DefaultHashTable<TKey, TValue, TAllocator>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more