Struct concread::bptree::BptreeMapWriteTxn
source · [−]pub struct BptreeMapWriteTxn<'a, K, V> where
K: Ord + Clone + Debug + Sync + Send + 'static,
V: Clone + Sync + Send + 'static, { /* 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 percieve changes in new transactions.
Implementations
sourceimpl<'a, K: Clone + Ord + Debug + Sync + Send + 'static, V: Clone + Sync + Send + 'static> BptreeMapWriteTxn<'a, K, V>
impl<'a, K: Clone + Ord + Debug + Sync + Send + 'static, V: Clone + Sync + Send + 'static> BptreeMapWriteTxn<'a, K, V>
sourcepub fn get<'b, Q: ?Sized>(&'a self, k: &'b Q) -> Option<&'a V> where
K: Borrow<Q>,
Q: Ord,
pub fn get<'b, Q: ?Sized>(&'a self, k: &'b Q) -> Option<&'a V> where
K: Borrow<Q>,
Q: Ord,
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<'b, Q: ?Sized>(&'a self, k: &'b Q) -> bool where
K: Borrow<Q>,
Q: Ord,
pub fn contains_key<'b, Q: ?Sized>(&'a self, k: &'b Q) -> bool where
K: Borrow<Q>,
Q: Ord,
Assert if a key exists in the tree.
sourcepub fn range<'b, R, T>(&'b self, range: R) -> RangeIter<'b, K, V>ⓘNotable traits for RangeIter<'a, K, V>impl<'a, K: Clone + Ord + Debug, V: Clone> Iterator for RangeIter<'a, K, V> type Item = (&'a K, &'a V);
where
K: Borrow<T>,
T: Ord,
R: RangeBounds<T>,
pub fn range<'b, R, T>(&'b self, range: R) -> RangeIter<'b, K, V>ⓘNotable traits for RangeIter<'a, K, V>impl<'a, K: Clone + Ord + Debug, V: Clone> Iterator for RangeIter<'a, K, V> type Item = (&'a K, &'a V);
where
K: Borrow<T>,
T: Ord,
R: RangeBounds<T>,
Iterate over a range of values
sourcepub fn iter(&self) -> Iter<'_, K, V>ⓘNotable traits for Iter<'a, K, V>impl<'a, K: Clone + Ord + Debug, V: Clone> Iterator for Iter<'a, K, V> type Item = (&'a K, &'a V);
pub fn iter(&self) -> Iter<'_, K, V>ⓘNotable traits for Iter<'a, K, V>impl<'a, K: Clone + Ord + Debug, V: Clone> Iterator for Iter<'a, K, V> type Item = (&'a K, &'a V);
Iterator over (&K, &V)
of the set
sourcepub fn values(&self) -> ValueIter<'_, K, V>ⓘNotable traits for ValueIter<'a, K, V>impl<'a, K: Clone + Ord + Debug, V: Clone> Iterator for ValueIter<'a, K, V> type Item = &'a V;
pub fn values(&self) -> ValueIter<'_, K, V>ⓘNotable traits for ValueIter<'a, K, V>impl<'a, K: Clone + Ord + Debug, V: Clone> Iterator for ValueIter<'a, K, V> type Item = &'a V;
Iterator over &K
sourcepub fn keys(&self) -> KeyIter<'_, K, V>ⓘNotable traits for KeyIter<'a, K, V>impl<'a, K: Clone + Ord + Debug, V: Clone> Iterator for KeyIter<'a, K, V> type Item = &'a K;
pub fn keys(&self) -> KeyIter<'_, K, V>ⓘNotable traits for KeyIter<'a, K, V>impl<'a, K: Clone + Ord + Debug, V: Clone> Iterator for KeyIter<'a, K, V> type Item = &'a K;
Iterator over &V
sourcepub fn range_mut<'b, R, T>(&'b mut self, range: R) -> RangeIterMut<'b, K, V>ⓘNotable traits for RangeIterMut<'a, K, V>impl<'a, K: Clone + Ord + Debug, V: Clone> Iterator for RangeIterMut<'a, K, V> type Item = (&'a K, &'a mut V);
where
K: Borrow<T>,
T: Ord,
R: RangeBounds<T>,
pub fn range_mut<'b, R, T>(&'b mut self, range: R) -> RangeIterMut<'b, K, V>ⓘNotable traits for RangeIterMut<'a, K, V>impl<'a, K: Clone + Ord + Debug, V: Clone> Iterator for RangeIterMut<'a, K, V> type Item = (&'a K, &'a mut V);
where
K: Borrow<T>,
T: Ord,
R: RangeBounds<T>,
Iterate over a range of values with mutable values
sourcepub fn iter_mut(&mut self) -> IterMut<'_, K, V>ⓘNotable traits for IterMut<'a, K, V>impl<'a, K: Clone + Ord + Debug, V: Clone> Iterator for IterMut<'a, K, V> type Item = (&'a K, &'a mut V);
pub fn iter_mut(&mut self) -> IterMut<'_, K, V>ⓘNotable traits for IterMut<'a, K, V>impl<'a, K: Clone + Ord + Debug, V: Clone> Iterator for IterMut<'a, K, V> type Item = (&'a K, &'a mut V);
Iterator over (&K, &mut V)
of the set
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 commited.
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 to_snapshot(&'a self) -> BptreeMapReadSnapshot<'_, K, V>
pub fn to_snapshot(&'a 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
sourceimpl<'a, K: Clone + Ord + Debug + Sync + Send + 'static, V: Clone + Sync + Send + 'static> Extend<(K, V)> for BptreeMapWriteTxn<'a, K, V>
impl<'a, K: Clone + Ord + Debug + Sync + Send + 'static, V: Clone + Sync + Send + 'static> Extend<(K, V)> for BptreeMapWriteTxn<'a, K, V>
sourcefn extend<I: IntoIterator<Item = (K, V)>>(&mut self, iter: I)
fn extend<I: IntoIterator<Item = (K, V)>>(&mut self, iter: I)
Extends a collection with the contents of an iterator. Read more
sourcefn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
extend_one
)Extends a collection with exactly one element.
sourcefn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one
)Reserves capacity in a collection for the given number of additional elements. Read more
Auto Trait Implementations
impl<'a, K, V> RefUnwindSafe for BptreeMapWriteTxn<'a, K, V> where
K: RefUnwindSafe,
V: RefUnwindSafe,
impl<'a, K, V> !Send for BptreeMapWriteTxn<'a, K, V>
impl<'a, K, V> Sync for BptreeMapWriteTxn<'a, K, V>
impl<'a, K, V> Unpin for BptreeMapWriteTxn<'a, K, V>
impl<'a, K, V> UnwindSafe for BptreeMapWriteTxn<'a, K, V> where
K: RefUnwindSafe,
V: RefUnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more