delta_btree_map

Struct DeltaBTreeMap

source
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>

source

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().

source

pub fn snapshot(&self) -> &'a BTreeMap<K, V>

Get a reference to the snapshot.

source

pub fn delta(&self) -> &'a BTreeMap<K, Change<V>>

Get a reference to the delta.

source

pub fn first_key(&self) -> Option<&'a K>

Get the first key in the updated version of the snapshot. Complexity: O(1).

source

pub fn last_key(&self) -> Option<&'a K>

Get the last key in the updated version of the snapshot. Complexity: O(1).

source

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.

source

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.

source

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.

source

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>
where &'a BTreeMap<K, V>: Copy, &'a BTreeMap<K, Change<V>>: Copy, Option<&'a K>: Copy,

source§

fn clone(&self) -> Self

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<'a, K: Debug + Ord, V: Debug> Debug for DeltaBTreeMap<'a, K, V>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<'a, K: Ord, V> Copy for DeltaBTreeMap<'a, K, V>
where &'a BTreeMap<K, V>: Copy, &'a BTreeMap<K, Change<V>>: Copy, Option<&'a K>: Copy,

Auto Trait Implementations§

§

impl<'a, K, V> Freeze for DeltaBTreeMap<'a, K, V>

§

impl<'a, K, V> RefUnwindSafe for DeltaBTreeMap<'a, K, V>

§

impl<'a, K, V> Send for DeltaBTreeMap<'a, K, V>
where K: Sync, V: Sync,

§

impl<'a, K, V> Sync for DeltaBTreeMap<'a, K, V>
where K: Sync, V: Sync,

§

impl<'a, K, V> Unpin for DeltaBTreeMap<'a, K, V>

§

impl<'a, K, V> UnwindSafe for DeltaBTreeMap<'a, K, V>

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> CloneToUninit for T
where T: Clone,

source§

unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for T
where T: Clone,

source§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

source§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.