pub struct BytellHashTable<TKey, TValue, TConfig>{ /* private fields */ }Expand description
The bytell hash table.
Implementations§
Source§impl<TKey, TValue, TConfig> BytellHashTable<TKey, TValue, TConfig>
impl<TKey, TValue, TConfig> BytellHashTable<TKey, TValue, TConfig>
Sourcepub fn new() -> Selfwhere
TConfig: Default,
pub fn new() -> Selfwhere
TConfig: Default,
Creates a new BytellHashTable with the default configuration.
Sourcepub const fn with_config(config: TConfig) -> Self
pub const fn with_config(config: TConfig) -> Self
Creates a new BytellHashTable with the specified configuration.
Sourcepub fn with_capacity(capacity: Length) -> Result<Self, HashTableError>where
TConfig: Default,
pub fn with_capacity(capacity: Length) -> Result<Self, HashTableError>where
TConfig: Default,
Creates a new BytellHashTable with the specified capacity and the default configuration.
§Errors
For details see HashTableError.
Sourcepub fn with_capacity_and_config(
capacity: Length,
config: TConfig,
) -> Result<Self, HashTableError>
pub fn with_capacity_and_config( capacity: Length, config: TConfig, ) -> Result<Self, HashTableError>
Creates a new BytellHashTable expected to support passed number_of_items.
§Notes
This method will almost surely overallocate, since it takes config.load_factor()
into account.
§Errors
For details see HashTableError.
Sourcepub fn shrink_to_fit(&mut self) -> Result<(), HashTableError>
pub fn shrink_to_fit(&mut self) -> Result<(), HashTableError>
Reduces the memory of the current table, if possible.
§Notes
If the number of underlying blocks cannot be reduced, it does nothing.
Otherwise it tries to reduce the number of blocks to the
minimal possible, creates a new table with that layout,
and moves (rehases) items into it. Then overwrites self
with the new table.
§Errors
For details see HashTableError.
Sourcepub const fn length(&self) -> Length
pub const fn length(&self) -> Length
Returns the length of the BytellHashTable.
Sourcepub const fn capacity(&self) -> PowerOfTwo32
pub const fn capacity(&self) -> PowerOfTwo32
Returns the capacity of the BytellHashTable.
Trait Implementations§
Source§impl<TKey, TValue, TConfig> Clone for BytellHashTable<TKey, TValue, TConfig>
impl<TKey, TValue, TConfig> Clone for BytellHashTable<TKey, TValue, TConfig>
Source§impl<TKey, TValue: Debug, TConfig> Debug for BytellHashTable<TKey, TValue, TConfig>
impl<TKey, TValue: Debug, TConfig> Debug for BytellHashTable<TKey, TValue, TConfig>
Source§impl<TKey, TValue, TConfig> Default for BytellHashTable<TKey, TValue, TConfig>
impl<TKey, TValue, TConfig> Default for BytellHashTable<TKey, TValue, TConfig>
Source§impl<'de, TKey, TValue, TConfig> Deserialize<'de> for BytellHashTable<TKey, TValue, TConfig>where
TKey: Eq + Hash + Deserialize<'de>,
TValue: Deserialize<'de>,
TConfig: BytellConfig + Default,
Available on crate feature serde only.
impl<'de, TKey, TValue, TConfig> Deserialize<'de> for BytellHashTable<TKey, TValue, TConfig>where
TKey: Eq + Hash + Deserialize<'de>,
TValue: Deserialize<'de>,
TConfig: BytellConfig + Default,
serde only.Source§fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
Source§impl<TKey, TValue, TConfig> Drop for BytellHashTable<TKey, TValue, TConfig>
impl<TKey, TValue, TConfig> Drop for BytellHashTable<TKey, TValue, TConfig>
impl<TKey, TValue, TConfig> Eq for BytellHashTable<TKey, TValue, TConfig>
Source§impl<TKey, TValue, TConfig> Hash for BytellHashTable<TKey, TValue, TConfig>
impl<TKey, TValue, TConfig> Hash for BytellHashTable<TKey, TValue, TConfig>
Source§impl<TKey, TValue, TConfig> ImmutableHashTable<TKey, TValue> for BytellHashTable<TKey, TValue, TConfig>
impl<TKey, TValue, TConfig> ImmutableHashTable<TKey, TValue> for BytellHashTable<TKey, TValue, TConfig>
Source§fn length(&self) -> Length
fn length(&self) -> Length
(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
key. Read moreSource§fn get<Q>(&self, key: &Q) -> Option<&TValue>
fn get<Q>(&self, key: &Q) -> Option<&TValue>
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<KVP<&TKey, &TValue>>
fn get_key_value<Q>(&self, key: &Q) -> Option<KVP<&TKey, &TValue>>
key, and if so then returns
the (&TKey, &TValue) pair or None otherwise. Read moreSource§impl<TKey, TValue, TConfig> MutableHashTable<TKey, TValue> for BytellHashTable<TKey, TValue, TConfig>
impl<TKey, TValue, TConfig> MutableHashTable<TKey, TValue> for BytellHashTable<TKey, TValue, TConfig>
Source§fn get_mut<Q>(&mut self, key: &Q) -> Option<&mut TValue>
fn get_mut<Q>(&mut self, key: &Q) -> Option<&mut TValue>
key, and if so then returns
a mutable reference to the TValue, or None otherwise. Read moreSource§fn get_key_value_mut<Q>(&mut self, key: &Q) -> Option<KVP<&TKey, &mut TValue>>
fn get_key_value_mut<Q>(&mut self, key: &Q) -> Option<KVP<&TKey, &mut TValue>>
key, and if so then returns
a mutable reference to the TValue, or None otherwise. Read moreSource§fn remove_entry<Q>(&mut self, key: &Q) -> Option<KVP<TKey, TValue>>
fn remove_entry<Q>(&mut self, key: &Q) -> Option<KVP<TKey, TValue>>
(TKey, TValue) pair
for the matching key or None if there is no match. Read moreSource§fn try_insert_or_update_with<'a, FAdd, FUpdate>(
&mut self,
key: TKey,
adder: FAdd,
updater: FUpdate,
) -> Result<&mut TValue, HashTableError>
fn try_insert_or_update_with<'a, FAdd, FUpdate>( &mut self, key: TKey, adder: FAdd, updater: FUpdate, ) -> Result<&mut TValue, HashTableError>
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 = KVP<&'a TKey, &'a mut TValue>>where
TKey: 'a,
TValue: 'a,
Self: 'a,
fn iter_mut<'a>(
&'a mut self,
) -> impl Iterator<Item = KVP<&'a TKey, &'a mut TValue>>where
TKey: 'a,
TValue: 'a,
Self: 'a,
Source§fn insert(&mut self, key: TKey, value: TValue) -> Option<TValue>
fn insert(&mut self, key: TKey, value: TValue) -> Option<TValue>
(TKey, TValue) pair into the table. Read moreSource§fn try_insert(
&mut self,
key: TKey,
value: TValue,
) -> Result<Option<TValue>, HashTableError>
fn try_insert( &mut self, key: TKey, value: TValue, ) -> Result<Option<TValue>, HashTableError>
(TKey, TValue) pair into the table. 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
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 remove<Q>(&mut self, key: &Q) -> Option<TValue>
fn remove<Q>(&mut self, key: &Q) -> Option<TValue>
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,
TValue, or inserts a default one. Read moreSource§fn try_get_or_insert_default(
&mut self,
key: TKey,
) -> Result<&mut TValue, HashTableError>where
TValue: Default,
fn try_get_or_insert_default(
&mut self,
key: TKey,
) -> Result<&mut TValue, HashTableError>where
TValue: Default,
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
TValue, or inserts the passed one. Read moreSource§fn try_get_or_insert(
&mut self,
key: TKey,
value: TValue,
) -> Result<&mut TValue, HashTableError>
fn try_get_or_insert( &mut self, key: TKey, value: TValue, ) -> Result<&mut TValue, HashTableError>
TValue, or inserts the passed one. Read moreSource§impl<TKey, TValue, TConfig> PartialEq for BytellHashTable<TKey, TValue, TConfig>
impl<TKey, TValue, TConfig> PartialEq for BytellHashTable<TKey, TValue, TConfig>
Source§impl<TKey, TValue, TConfig> ReprC for BytellHashTable<TKey, TValue, TConfig>
impl<TKey, TValue, TConfig> ReprC for BytellHashTable<TKey, TValue, TConfig>
impl<TKey, TValue, TConfig> Send for BytellHashTable<TKey, TValue, TConfig>
Source§impl<TKey, TValue, TConfig> Serialize for BytellHashTable<TKey, TValue, TConfig>
Available on crate feature serde only.
impl<TKey, TValue, TConfig> Serialize for BytellHashTable<TKey, TValue, TConfig>
serde only.