Struct concread::bptree::BptreeMapWriteTxn
source · pub struct BptreeMapWriteTxn<'a, K, V>{ /* private fields */ }
Expand description
An active write transaction for a BptreeMap. The data in this tree
may be modified exclusively through this transaction without affecting
readers. The write may be rolledback/aborted by dropping this guard
without calling commit()
. Once commit()
is called, readers will be
able to access and perceive changes in new transactions.
Implementations§
source§impl<K: Clone + Ord + Debug + Sync + Send + 'static, V: Clone + Sync + Send + 'static> BptreeMapWriteTxn<'_, K, V>
impl<K: Clone + Ord + Debug + Sync + Send + 'static, V: Clone + Sync + Send + 'static> BptreeMapWriteTxn<'_, K, V>
sourcepub fn get<Q>(&self, k: &Q) -> Option<&V>
pub fn get<Q>(&self, k: &Q) -> Option<&V>
Retrieve a value from the tree. If the value exists, a reference is returned
as Some(&V)
, otherwise if not present None
is returned.
sourcepub fn contains_key<Q>(&self, k: &Q) -> bool
pub fn contains_key<Q>(&self, k: &Q) -> bool
Assert if a key exists in the tree.
sourcepub fn range<R, T>(&self, range: R) -> RangeIter<'_, '_, K, V> ⓘ
pub fn range<R, T>(&self, range: R) -> RangeIter<'_, '_, K, V> ⓘ
Iterate over a range of values
sourcepub fn first_key_value(&self) -> Option<(&K, &V)>
pub fn first_key_value(&self) -> Option<(&K, &V)>
Retrieve the first (minimum) key-value pair from the map if it exists.
sourcepub fn last_key_value(&self) -> Option<(&K, &V)>
pub fn last_key_value(&self) -> Option<(&K, &V)>
Retrieve the last (maximum) key-value pair from the map if it exists.
sourcepub fn clear(&mut self)
pub fn clear(&mut self)
Reset this tree to an empty state. As this is within the transaction this change only takes effect once committed.
sourcepub fn insert(&mut self, k: K, v: V) -> Option<V>
pub fn insert(&mut self, k: K, v: V) -> Option<V>
Insert or update a value by key. If the value previously existed it is returned
as Some(V)
. If the value did not previously exist this returns None
.
sourcepub fn remove(&mut self, k: &K) -> Option<V>
pub fn remove(&mut self, k: &K) -> Option<V>
Remove a key if it exists in the tree. If the value exists, we return it as Some(V)
,
and if it did not exist, we return None
sourcepub fn split_off_lt(&mut self, key: &K)
pub fn split_off_lt(&mut self, key: &K)
Remove all values less than (but not including) key from the map.
sourcepub fn get_mut(&mut self, key: &K) -> Option<&mut V>
pub fn get_mut(&mut self, key: &K) -> Option<&mut V>
Get a mutable reference to a value in the tree. This is correctly, and safely cloned before you attempt to mutate the value, isolating it from other transactions.
sourcepub fn range_mut<R, T>(&mut self, range: R) -> RangeMutIter<'_, '_, K, V> ⓘ
pub fn range_mut<R, T>(&mut self, range: R) -> RangeMutIter<'_, '_, K, V> ⓘ
Iterate over a mutable range of values
sourcepub fn to_snapshot(&self) -> BptreeMapReadSnapshot<'_, K, V>
pub fn to_snapshot(&self) -> BptreeMapReadSnapshot<'_, K, V>
Create a read-snapshot of the current tree. This does NOT guarantee the tree may not be mutated during the read, so you MUST guarantee that no functions of the write txn are called while this snapshot is active.
Trait Implementations§
source§impl<K: Clone + Ord + Debug + Sync + Send + 'static, V: Clone + Sync + Send + 'static> Extend<(K, V)> for BptreeMapWriteTxn<'_, K, V>
impl<K: Clone + Ord + Debug + Sync + Send + 'static, V: Clone + Sync + Send + 'static> Extend<(K, V)> for BptreeMapWriteTxn<'_, K, V>
source§fn extend<I: IntoIterator<Item = (K, V)>>(&mut self, iter: I)
fn extend<I: IntoIterator<Item = (K, V)>>(&mut self, iter: I)
source§fn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
extend_one
)source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one
)