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.