Struct LegacyTreeMap

Source
pub struct LegacyTreeMap<K, V> { /* private fields */ }
๐Ÿ‘ŽDeprecated since 2.1.0: Use unc_sdk::collections::TreeMap
Expand description

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ยง

Sourceยง

impl<K, V> LegacyTreeMap<K, V>

Source

pub fn new<S>(prefix: S) -> Self
where S: IntoStorageKey,

Source

pub fn len(&self) -> u64

Source

pub fn clear(&mut self)

Source

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

Source

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

Source

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

Source

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

Source

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

Returns the smallest stored key from the tree

Source

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

Returns the largest stored key from the tree

Source

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

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

Source

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

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

Source

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

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

Source

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

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

Source

pub fn iter(&self) -> impl Iterator<Item = (K, V)> + '_

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

Source

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

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

Source

pub fn iter_rev(&self) -> impl Iterator<Item = (K, V)> + '_

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

Source

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

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

Source

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.

Source

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ยง

Sourceยง

impl<K, V> BorshDeserialize for LegacyTreeMap<K, V>

Sourceยง

fn deserialize_reader<__R: Read>(reader: &mut __R) -> Result<Self, Error>

Sourceยง

fn deserialize(buf: &mut &[u8]) -> Result<Self, Error>

Deserializes this instance from a given slice of bytes. Updates the buffer to point at the remaining bytes.
Sourceยง

fn try_from_slice(v: &[u8]) -> Result<Self, Error>

Deserialize this instance from a slice of bytes.
Sourceยง

fn try_from_reader<R>(reader: &mut R) -> Result<Self, Error>
where R: Read,

Sourceยง

impl<K, V> BorshSerialize for LegacyTreeMap<K, V>

Sourceยง

fn serialize<__W: Write>(&self, writer: &mut __W) -> Result<(), Error>

Sourceยง

impl<'a, K, V> IntoIterator for &'a LegacyTreeMap<K, V>

Sourceยง

type Item = (K, V)

The type of the elements being iterated over.
Sourceยง

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

Which kind of iterator are we turning this into?
Sourceยง

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more

Auto Trait Implementationsยง

ยง

impl<K, V> Freeze for LegacyTreeMap<K, V>

ยง

impl<K, V> RefUnwindSafe for LegacyTreeMap<K, V>

ยง

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ยง

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> 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, 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.