pub struct Table<'txn, K: Key + 'static, V: Value + 'static> { /* private fields */ }
Expand description
A table containing key-value mappings
Implementations§
source§impl<'txn, K: Key + 'static, V: Value + 'static> Table<'txn, K, V>
impl<'txn, K: Key + 'static, V: Value + 'static> Table<'txn, K, V>
sourcepub fn pop_first(
&mut self,
) -> Result<Option<(AccessGuard<'_, K>, AccessGuard<'_, V>)>>
pub fn pop_first( &mut self, ) -> Result<Option<(AccessGuard<'_, K>, AccessGuard<'_, V>)>>
Removes and returns the first key-value pair in the table
sourcepub fn pop_last(
&mut self,
) -> Result<Option<(AccessGuard<'_, K>, AccessGuard<'_, V>)>>
pub fn pop_last( &mut self, ) -> Result<Option<(AccessGuard<'_, K>, AccessGuard<'_, V>)>>
Removes and returns the last key-value pair in the table
sourcepub fn extract_if<F: for<'f> FnMut(K::SelfType<'f>, V::SelfType<'f>) -> bool>(
&mut self,
predicate: F,
) -> Result<ExtractIf<'_, K, V, F>>
pub fn extract_if<F: for<'f> FnMut(K::SelfType<'f>, V::SelfType<'f>) -> bool>( &mut self, predicate: F, ) -> Result<ExtractIf<'_, K, V, F>>
Applies predicate
to all key-value pairs. All entries for which
predicate
evaluates to true
are returned in an iterator, and those which are read from the iterator are removed
Note: values not read from the iterator will not be removed
sourcepub fn extract_from_if<'a, KR, F: for<'f> FnMut(K::SelfType<'f>, V::SelfType<'f>) -> bool>(
&mut self,
range: impl RangeBounds<KR> + 'a,
predicate: F,
) -> Result<ExtractIf<'_, K, V, F>>
pub fn extract_from_if<'a, KR, F: for<'f> FnMut(K::SelfType<'f>, V::SelfType<'f>) -> bool>( &mut self, range: impl RangeBounds<KR> + 'a, predicate: F, ) -> Result<ExtractIf<'_, K, V, F>>
Applies predicate
to all key-value pairs in the specified range. All entries for which
predicate
evaluates to true
are returned in an iterator, and those which are read from the iterator are removed
Note: values not read from the iterator will not be removed
sourcepub fn retain<F: for<'f> FnMut(K::SelfType<'f>, V::SelfType<'f>) -> bool>(
&mut self,
predicate: F,
) -> Result
pub fn retain<F: for<'f> FnMut(K::SelfType<'f>, V::SelfType<'f>) -> bool>( &mut self, predicate: F, ) -> Result
Applies predicate
to all key-value pairs. All entries for which
predicate
evaluates to false
are removed.
sourcepub fn retain_in<'a, KR, F: for<'f> FnMut(K::SelfType<'f>, V::SelfType<'f>) -> bool>(
&mut self,
range: impl RangeBounds<KR> + 'a,
predicate: F,
) -> Result
pub fn retain_in<'a, KR, F: for<'f> FnMut(K::SelfType<'f>, V::SelfType<'f>) -> bool>( &mut self, range: impl RangeBounds<KR> + 'a, predicate: F, ) -> Result
Applies predicate
to all key-value pairs in the range start..end
. All entries for which
predicate
evaluates to false
are removed.
sourcepub fn insert<'k, 'v>(
&mut self,
key: impl Borrow<K::SelfType<'k>>,
value: impl Borrow<V::SelfType<'v>>,
) -> Result<Option<AccessGuard<'_, V>>>
pub fn insert<'k, 'v>( &mut self, key: impl Borrow<K::SelfType<'k>>, value: impl Borrow<V::SelfType<'v>>, ) -> Result<Option<AccessGuard<'_, V>>>
Insert mapping of the given key to the given value
If key is already present it is replaced
Returns the old value, if the key was present in the table, otherwise None is returned
source§impl<'txn, K: Key + 'static, V: MutInPlaceValue + 'static> Table<'txn, K, V>
impl<'txn, K: Key + 'static, V: MutInPlaceValue + 'static> Table<'txn, K, V>
sourcepub fn insert_reserve<'a>(
&mut self,
key: impl Borrow<K::SelfType<'a>>,
value_length: u32,
) -> Result<AccessGuardMut<'_, V>>
pub fn insert_reserve<'a>( &mut self, key: impl Borrow<K::SelfType<'a>>, value_length: u32, ) -> Result<AccessGuardMut<'_, V>>
Reserve space to insert a key-value pair
If key is already present it is replaced
The returned reference will have length equal to value_length