Enum dusk_kelvin_map::KelvinMap[][src]

pub enum KelvinMap<K, V, A> where
    K: Canon + Ord,
    V: Canon,
    A: MapAnnotation<K, V>, 
{ Empty, Leaf(Leaf<K, V>), Node(Annotated<KelvinMap<K, V, A>, A>, Annotated<KelvinMap<K, V, A>, A>), }

Binary tree map-like implementation with Microkelvin set as backend

The borrowed [Max] from the annotation will be used to traverse the tree and is expected to be the maximum K contained in that sub-tree.

Variants

Empty

Represents and empty endpoint

Leaf(Leaf<K, V>)

Leaf of the tree containing a key -> value mapping

Node(Annotated<KelvinMap<K, V, A>, A>, Annotated<KelvinMap<K, V, A>, A>)

Annotated node that will contain, at least, the maximum key value that exists within this sub-tree

Implementations

impl<K, V, A> KelvinMap<K, V, A> where
    K: Canon + Ord,
    V: Canon,
    A: MapAnnotation<K, V>, 
[src]

pub fn len(&self) -> usize[src]

Returns the number of elements in the map.

pub fn is_empty(&self) -> bool[src]

Check if the map is empty

pub fn get<'a>(
    &'a self,
    k: &K
) -> Result<Option<impl Deref<Target = V> + 'a>, CanonError>
[src]

Returns a reference to the value corresponding to the key

Will return Ok(None) if no correspondent key was found.

pub fn get_mut<'a>(
    &'a mut self,
    k: &K
) -> Result<Option<impl DerefMut<Target = V> + 'a>, CanonError>
[src]

Returns a mutable reference to the value corresponding to the key

Will return Ok(None) if no correspondent key was found.

pub fn remove(&mut self, k: &K) -> Result<Option<V>, CanonError>[src]

Remove a key -> value mapping from the set.

If the key was previously mapped, it will return the old value in the form Ok(Some(V)).

If the key was not previously mapped, the return will be Ok(None). This operation is idempotent.

Internally, a naive balancing will be performed. If the tree contains more elements on the left, it will move the maximum key of the left to the right - and vice-versa.

pub fn insert(&mut self, k: K, v: V) -> Result<Option<V>, CanonError>[src]

Include a key -> value mapping to the set.

If the key was previously mapped, it will return the old value in the form Ok(Some(V)).

If the key was not previously mapped, the return will be Ok(None)

Internally, a naive balancing will be performed. If the tree contains more elements on the left, it will move the maximum key of the left to the right - and vice-versa.

Trait Implementations

impl<K: Canon, V: Canon, A: Canon> Canon for KelvinMap<K, V, A> where
    K: Canon + Ord,
    V: Canon,
    A: MapAnnotation<K, V>, 
[src]

fn encode(&self, sink: &mut Sink<'_>)[src]

Write the value as bytes to a Sink

fn decode(source: &mut Source<'_>) -> Result<Self, CanonError>[src]

Read the value from bytes in a Source

fn encoded_len(&self) -> usize[src]

Returns the number of bytes needed to encode this value

impl<K: Clone, V: Clone, A: Clone> Clone for KelvinMap<K, V, A> where
    K: Canon + Ord,
    V: Canon,
    A: MapAnnotation<K, V>, 
[src]

fn clone(&self) -> KelvinMap<K, V, A>[src]

Returns a copy of the value. Read more

fn clone_from(&mut self, source: &Self)1.0.0[src]

Performs copy-assignment from source. Read more

impl<K, V> Combine<KelvinMap<K, V, MapAnnotationDefault<K>>, MapAnnotationDefault<K>> for MapAnnotationDefault<K> where
    K: Canon + Ord + Default,
    V: Canon
[src]

fn combine(node: &KelvinMap<K, V, MapAnnotationDefault<K>>) -> Self[src]

Combines multiple annotations

impl<K, V, A> Compound<A> for KelvinMap<K, V, A> where
    V: Canon,
    K: Canon + Ord,
    A: MapAnnotation<K, V>, 
[src]

type Leaf = Leaf<K, V>

The leaf type of the Compound collection

fn child(&self, ofs: usize) -> Child<'_, Self, A>[src]

Returns a reference to a possible child at specified offset

fn child_mut(&mut self, ofs: usize) -> ChildMut<'_, Self, A>[src]

Returns a mutable reference to a possible child at specified offset

fn children(&self) -> ChildIterator<'_, Self, A>[src]

Returns an iterator over the children of the Compound node.

impl<K: Debug, V: Debug, A: Debug> Debug for KelvinMap<K, V, A> where
    K: Canon + Ord,
    V: Canon,
    A: MapAnnotation<K, V>, 
[src]

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

Formats the value using the given formatter. Read more

impl<K, V, A> Default for KelvinMap<K, V, A> where
    K: Canon + Ord,
    V: Canon,
    A: MapAnnotation<K, V>, 
[src]

fn default() -> Self[src]

Returns the “default value” for a type. Read more

Auto Trait Implementations

impl<K, V, A> !RefUnwindSafe for KelvinMap<K, V, A>

impl<K, V, A> !Send for KelvinMap<K, V, A>

impl<K, V, A> !Sync for KelvinMap<K, V, A>

impl<K, V, A> Unpin for KelvinMap<K, V, A> where
    K: Unpin,
    V: Unpin

impl<K, V, A> !UnwindSafe for KelvinMap<K, V, A>

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

pub fn type_id(&self) -> TypeId[src]

Gets the TypeId of self. Read more

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

pub fn borrow(&self) -> &T[src]

Immutably borrows from an owned value. Read more

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

pub fn borrow_mut(&mut self) -> &mut T[src]

Mutably borrows from an owned value. Read more

impl<T> EncodeToVec for T where
    T: Canon
[src]

pub fn encode_to_vec(&self) -> Vec<u8, Global>[src]

Encode Self into a buffer

impl<'a, C, A> First<'a, A> for C where
    C: Compound<A> + Clone,
    A: Combine<C, A>, 
[src]

pub fn first(&'a self) -> Result<Option<Branch<'a, C, A>>, CanonError>[src]

Construct a Branch pointing to the first element, if not empty

pub fn first_mut(
    &'a mut self
) -> Result<Option<BranchMut<'a, C, A>>, CanonError> where
    C: MutableLeaves,
    A: Combine<C, A>, 
[src]

Construct a BranchMut pointing to the first element, if not empty

impl<T> From<T> for T[src]

pub fn from(t: T) -> T[src]

Performs the conversion.

impl<'a, C, A, K> GetMaxKey<'a, A, K> for C where
    C: Compound<A> + Clone,
    K: Ord + Clone + Debug,
    A: Combine<C, A> + Borrow<MaxKey<K>>,
    <C as Compound<A>>::Leaf: Keyed<K>, 
[src]

pub fn max_key(&'a self) -> Result<Option<Branch<'a, C, A>>, CanonError>[src]

Construct a Branch pointing to the element with the largest key

pub fn max_key_mut(
    &'a mut self
) -> Result<Option<BranchMut<'a, C, A>>, CanonError> where
    C: MutableLeaves,
    A: Combine<C, A>, 
[src]

Construct a BranchMut pointing to the element with the largest key

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

pub fn into(self) -> U[src]

Performs the conversion.

impl<T> Keyed<T> for T[src]

pub fn key(&self) -> &T[src]

Return a reference to the key of the leaf type

impl<'a, C, A> Nth<'a, A> for C where
    C: Compound<A> + Clone,
    A: Combine<C, A> + Borrow<Cardinality>, 
[src]

pub fn nth(&'a self, ofs: u64) -> Result<Option<Branch<'a, C, A>>, CanonError>[src]

Construct a Branch pointing to the nth element, if any

pub fn nth_mut(
    &'a mut self,
    ofs: u64
) -> Result<Option<BranchMut<'a, C, A>>, CanonError> where
    C: MutableLeaves,
    A: Combine<C, A>, 
[src]

Construct a BranchMut pointing to the nth element, if any

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

pub fn to_owned(&self) -> T[src]

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

pub fn clone_into(&self, target: &mut T)[src]

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

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

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

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

Performs the conversion.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

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

Performs the conversion.