Struct unc_sdk::collections::LegacyTreeMap

source ยท
pub struct LegacyTreeMap<K, V> { /* private fields */ }
๐Ÿ‘ŽDeprecated since 4.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>

ยง

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

ยง

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

ยง

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.