[][src]Struct near_sdk::collections::TreeMap

pub struct TreeMap<K, V> { /* fields omitted */ }

TreeMap based on AVL-tree

Runtime complexity (worst case):

  • get/contains_key: O(1) - UnorderedMap lookup
  • insert/remove: O(log(N))
  • min/max: O(log(N))
  • above/below: O(log(N))
  • range of K elements: O(Klog(N))

Implementations

impl<K, V> TreeMap<K, V> where
    K: Ord + Clone + BorshSerialize + BorshDeserialize,
    V: BorshSerialize + BorshDeserialize
[src]

pub fn new(id: Vec<u8>) -> Self[src]

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

pub fn clear(&mut self)[src]

pub fn contains_key(&self, key: &K) -> bool[src]

pub fn get(&self, key: &K) -> Option<V>[src]

pub fn insert(&mut self, key: &K, val: &V) -> Option<V>[src]

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

pub fn min(&self) -> Option<K>[src]

Returns the smallest stored key from the tree

pub fn max(&self) -> Option<K>[src]

Returns the largest stored key from the tree

pub fn higher(&self, key: &K) -> Option<K>[src]

Returns the smallest key that is strictly greater than key given as the parameter

pub fn lower(&self, key: &K) -> Option<K>[src]

Returns the largest key that is strictly less than key given as the parameter

pub fn ceil_key(&self, key: &K) -> Option<K>[src]

Returns the smallest key that is greater or equal to key given as the parameter

pub fn floor_key(&self, key: &K) -> Option<K>[src]

Returns the largest key that is less or equal to key given as the parameter

pub fn iter<'a>(&'a self) -> impl Iterator<Item = (K, V)> + 'a[src]

Iterate all entries in ascending order: min to max, both inclusive

pub fn iter_from<'a>(&'a self, key: K) -> impl Iterator<Item = (K, V)> + 'a[src]

Iterate entries in ascending order: given key (exclusive) to max (inclusive)

pub fn iter_rev<'a>(&'a self) -> impl Iterator<Item = (K, V)> + 'a[src]

Iterate all entries in descending order: max to min, both inclusive

pub fn iter_rev_from<'a>(&'a self, key: K) -> impl Iterator<Item = (K, V)> + 'a[src]

Iterate entries in descending order: given key (exclusive) to min (inclusive)

pub fn range<'a>(
    &'a self,
    r: (Bound<K>, Bound<K>)
) -> impl Iterator<Item = (K, V)> + 'a
[src]

Iterate entries in ascending order according to specified bounds.

Panics

Panics if range start > end. Panics if range start == end and both bounds are Excluded.

pub fn to_vec(&self) -> Vec<(K, V)>[src]

Trait Implementations

impl<K, V> BorshDeserialize for TreeMap<K, V> where
    u64: BorshDeserialize,
    UnorderedMap<K, V>: BorshDeserialize,
    Vector<Node<K>>: BorshDeserialize
[src]

impl<K, V> BorshSerialize for TreeMap<K, V> where
    u64: BorshSerialize,
    UnorderedMap<K, V>: BorshSerialize,
    Vector<Node<K>>: BorshSerialize
[src]

impl<K, V> Default for TreeMap<K, V> where
    K: Ord + Clone + BorshSerialize + BorshDeserialize,
    V: BorshSerialize + BorshDeserialize
[src]

impl<'a, K, V> IntoIterator for &'a TreeMap<K, V> where
    K: Ord + Clone + BorshSerialize + BorshDeserialize,
    V: BorshSerialize + BorshDeserialize
[src]

type Item = (K, V)

The type of the elements being iterated over.

type IntoIter = Cursor<'a, K, V>

Which kind of iterator are we turning this into?

Auto Trait Implementations

impl<K, V> RefUnwindSafe for TreeMap<K, V> where
    K: RefUnwindSafe,
    V: RefUnwindSafe

impl<K, V> Send for TreeMap<K, V> where
    K: Send,
    V: Send

impl<K, V> Sync for TreeMap<K, V> where
    K: Sync,
    V: Sync

impl<K, V> Unpin for TreeMap<K, V> where
    K: Unpin,
    V: Unpin

impl<K, V> UnwindSafe for TreeMap<K, V> where
    K: UnwindSafe,
    V: UnwindSafe

Blanket Implementations

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

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

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

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

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

impl<T> Same<T> for T

type Output = T

Should always be Self

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.

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.