pub struct DeltaBTreeMap<'a, K: Ord, V> {
pub(crate) snapshot: &'a BTreeMap<K, V>,
pub(crate) delta: &'a BTreeMap<K, Change<V>>,
pub(crate) first_key: Option<&'a K>,
pub(crate) last_key: Option<&'a K>,
}
Expand description
DeltaBTreeMap
wraps two BTreeMap
references respectively as snapshot and delta,
providing cursor that can iterate over the updated version of the snapshot.
Fields§
§snapshot: &'a BTreeMap<K, V>
§delta: &'a BTreeMap<K, Change<V>>
§first_key: Option<&'a K>
§last_key: Option<&'a K>
Implementations§
source§impl<'a, K: Ord, V> DeltaBTreeMap<'a, K, V>
impl<'a, K: Ord, V> DeltaBTreeMap<'a, K, V>
sourcepub fn new(
snapshot: &'a BTreeMap<K, V>,
delta: &'a BTreeMap<K, Change<V>>,
) -> Self
pub fn new( snapshot: &'a BTreeMap<K, V>, delta: &'a BTreeMap<K, Change<V>>, ) -> Self
Create a new DeltaBTreeMap
from the given snapshot and delta.
Best case time complexity: O(1), worst case time complexity: O(m), where m is delta.len()
.
sourcepub fn first_key(&self) -> Option<&'a K>
pub fn first_key(&self) -> Option<&'a K>
Get the first key in the updated version of the snapshot. Complexity: O(1).
sourcepub fn last_key(&self) -> Option<&'a K>
pub fn last_key(&self) -> Option<&'a K>
Get the last key in the updated version of the snapshot. Complexity: O(1).
sourcepub fn before(&self, key: &K) -> Option<CursorWithDelta<'a, K, V>>
pub fn before(&self, key: &K) -> Option<CursorWithDelta<'a, K, V>>
Get a CursorWithDelta
pointing at the gap before the given given key.
If the given key is not found in either the snapshot or the delta, None
is returned.
sourcepub fn after(&self, key: &K) -> Option<CursorWithDelta<'a, K, V>>
pub fn after(&self, key: &K) -> Option<CursorWithDelta<'a, K, V>>
Get a CursorWithDelta
pointing at the gap after the given given key.
If the given key is not found in either the snapshot or the delta, None
is returned.
sourcepub fn lower_bound(&self, bound: Bound<&K>) -> CursorWithDelta<'a, K, V>
pub fn lower_bound(&self, bound: Bound<&K>) -> CursorWithDelta<'a, K, V>
Get a CursorWithDelta
pointing at the gap before the smallest key greater than the given bound.
sourcepub fn upper_bound(&self, bound: Bound<&K>) -> CursorWithDelta<'a, K, V>
pub fn upper_bound(&self, bound: Bound<&K>) -> CursorWithDelta<'a, K, V>
Get a CursorWithDelta
pointing at the gap after the greatest key smaller than the given bound.
Trait Implementations§
source§impl<'a, K: Ord, V> Clone for DeltaBTreeMap<'a, K, V>
impl<'a, K: Ord, V> Clone for DeltaBTreeMap<'a, K, V>
impl<'a, K: Ord, V> Copy for DeltaBTreeMap<'a, K, V>
Auto Trait Implementations§
impl<'a, K, V> Freeze for DeltaBTreeMap<'a, K, V>
impl<'a, K, V> RefUnwindSafe for DeltaBTreeMap<'a, K, V>where
K: RefUnwindSafe,
V: RefUnwindSafe,
impl<'a, K, V> Send for DeltaBTreeMap<'a, K, V>
impl<'a, K, V> Sync for DeltaBTreeMap<'a, K, V>
impl<'a, K, V> Unpin for DeltaBTreeMap<'a, K, V>
impl<'a, K, V> UnwindSafe for DeltaBTreeMap<'a, K, V>where
K: RefUnwindSafe,
V: RefUnwindSafe,
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
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)