Struct near_sdk::collections::LegacyTreeMap
source · [−]pub struct LegacyTreeMap<K, V> { /* private fields */ }
Expand description
TreeMap based on AVL-tree
Runtime complexity (worst case):
get
/contains_key
: O(1) - UnorderedMap lookupinsert
/remove
: O(log(N))min
/max
: O(log(N))above
/below
: O(log(N))range
of K elements: O(Klog(N))
Implementations
sourceimpl<K, V> LegacyTreeMap<K, V> where
K: Ord + Clone + BorshSerialize + BorshDeserialize,
V: BorshSerialize + BorshDeserialize,
impl<K, V> LegacyTreeMap<K, V> where
K: Ord + Clone + BorshSerialize + BorshDeserialize,
V: BorshSerialize + BorshDeserialize,
pub fn new<S>(prefix: S) -> Self where
S: IntoStorageKey,
pub fn len(&self) -> u64
pub fn clear(&mut self)
pub fn contains_key(&self, key: &K) -> bool
pub fn get(&self, key: &K) -> Option<V>
pub fn insert(&mut self, key: &K, val: &V) -> Option<V>
pub fn remove(&mut self, key: &K) -> Option<V>
sourcepub fn higher(&self, key: &K) -> Option<K>
pub fn higher(&self, key: &K) -> Option<K>
Returns the smallest key that is strictly greater than key given as the parameter
sourcepub fn lower(&self, key: &K) -> Option<K>
pub fn lower(&self, key: &K) -> Option<K>
Returns the largest key that is strictly less than key given as the parameter
sourcepub fn ceil_key(&self, key: &K) -> Option<K>
pub fn ceil_key(&self, key: &K) -> Option<K>
Returns the smallest key that is greater or equal to key given as the parameter
sourcepub fn floor_key(&self, key: &K) -> Option<K>
pub fn floor_key(&self, key: &K) -> Option<K>
Returns the largest key that is less or equal to key given as the parameter
sourcepub fn iter(&self) -> impl Iterator<Item = (K, V)> + '_
pub fn iter(&self) -> impl Iterator<Item = (K, V)> + '_
Iterate all entries in ascending order: min to max, both inclusive
sourcepub fn iter_from(&self, key: K) -> impl Iterator<Item = (K, V)> + '_
pub fn iter_from(&self, key: K) -> impl Iterator<Item = (K, V)> + '_
Iterate entries in ascending order: given key (exclusive) to max (inclusive)
sourcepub fn iter_rev(&self) -> impl Iterator<Item = (K, V)> + '_
pub fn iter_rev(&self) -> impl Iterator<Item = (K, V)> + '_
Iterate all entries in descending order: max to min, both inclusive
sourcepub fn iter_rev_from(&self, key: K) -> impl Iterator<Item = (K, V)> + '_
pub fn iter_rev_from(&self, key: K) -> impl Iterator<Item = (K, V)> + '_
Iterate entries in descending order: given key (exclusive) to min (inclusive)
sourcepub fn range(
&self,
r: (Bound<K>, Bound<K>)
) -> impl Iterator<Item = (K, V)> + '_
pub fn range(
&self,
r: (Bound<K>, Bound<K>)
) -> impl Iterator<Item = (K, V)> + '_
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.
sourcepub fn to_vec(&self) -> Vec<(K, V)>
pub fn to_vec(&self) -> Vec<(K, V)>
Helper function which creates a [Vec<(K, V)>
] of all items in the LegacyTreeMap
.
This function collects elements from LegacyTreeMap::iter
.
Trait Implementations
sourceimpl<K, V> BorshDeserialize for LegacyTreeMap<K, V> where
u64: BorshDeserialize,
UnorderedMap<K, V>: BorshDeserialize,
Vector<Node<K>>: BorshDeserialize,
impl<K, V> BorshDeserialize for LegacyTreeMap<K, V> where
u64: BorshDeserialize,
UnorderedMap<K, V>: BorshDeserialize,
Vector<Node<K>>: BorshDeserialize,
sourceimpl<K, V> BorshSerialize for LegacyTreeMap<K, V> where
u64: BorshSerialize,
UnorderedMap<K, V>: BorshSerialize,
Vector<Node<K>>: BorshSerialize,
impl<K, V> BorshSerialize for LegacyTreeMap<K, V> where
u64: BorshSerialize,
UnorderedMap<K, V>: BorshSerialize,
Vector<Node<K>>: BorshSerialize,
sourceimpl<'a, K, V> IntoIterator for &'a LegacyTreeMap<K, V> where
K: Ord + Clone + BorshSerialize + BorshDeserialize,
V: BorshSerialize + BorshDeserialize,
impl<'a, K, V> IntoIterator for &'a LegacyTreeMap<K, V> where
K: Ord + Clone + BorshSerialize + BorshDeserialize,
V: BorshSerialize + BorshDeserialize,
Auto Trait Implementations
impl<K, V> RefUnwindSafe for LegacyTreeMap<K, V> where
K: RefUnwindSafe,
V: RefUnwindSafe,
impl<K, V> Send for LegacyTreeMap<K, V> where
K: Send,
V: Send,
impl<K, V> Sync for LegacyTreeMap<K, V> where
K: Sync,
V: Sync,
impl<K, V> Unpin for LegacyTreeMap<K, V> where
K: Unpin,
V: Unpin,
impl<K, V> UnwindSafe for LegacyTreeMap<K, V> where
K: UnwindSafe,
V: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more