[−][src]Struct near_sdk::collections::TreeMap
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
impl<K, V> TreeMap<K, V> where
K: Ord + Clone + BorshSerialize + BorshDeserialize,
V: BorshSerialize + BorshDeserialize,
[src]
K: Ord + Clone + BorshSerialize + BorshDeserialize,
V: BorshSerialize + BorshDeserialize,
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]
&'a self,
r: (Bound<K>, Bound<K>)
) -> impl Iterator<Item = (K, V)> + 'a
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]
u64: BorshDeserialize,
UnorderedMap<K, V>: BorshDeserialize,
Vector<Node<K>>: BorshDeserialize,
fn deserialize(buf: &mut &[u8]) -> Result<Self, Error>
[src]
fn try_from_slice(v: &[u8]) -> Result<Self, Error>
[src]
fn is_u8() -> bool
[src]
impl<K, V> BorshSerialize for TreeMap<K, V> where
u64: BorshSerialize,
UnorderedMap<K, V>: BorshSerialize,
Vector<Node<K>>: BorshSerialize,
[src]
u64: BorshSerialize,
UnorderedMap<K, V>: BorshSerialize,
Vector<Node<K>>: BorshSerialize,
fn serialize<W: Write>(&self, writer: &mut W) -> Result<(), Error>
[src]
fn try_to_vec(&self) -> Result<Vec<u8>, Error>
[src]
fn is_u8() -> bool
[src]
impl<K, V> Default for TreeMap<K, V> where
K: Ord + Clone + BorshSerialize + BorshDeserialize,
V: BorshSerialize + BorshDeserialize,
[src]
K: Ord + Clone + BorshSerialize + BorshDeserialize,
V: BorshSerialize + BorshDeserialize,
impl<'a, K, V> IntoIterator for &'a TreeMap<K, V> where
K: Ord + Clone + BorshSerialize + BorshDeserialize,
V: BorshSerialize + BorshDeserialize,
[src]
K: Ord + Clone + BorshSerialize + BorshDeserialize,
V: BorshSerialize + BorshDeserialize,
Auto Trait Implementations
impl<K, V> RefUnwindSafe for TreeMap<K, V> where
K: RefUnwindSafe,
V: RefUnwindSafe,
K: RefUnwindSafe,
V: RefUnwindSafe,
impl<K, V> Send for TreeMap<K, V> where
K: Send,
V: Send,
K: Send,
V: Send,
impl<K, V> Sync for TreeMap<K, V> where
K: Sync,
V: Sync,
K: Sync,
V: Sync,
impl<K, V> Unpin for TreeMap<K, V> where
K: Unpin,
V: Unpin,
K: Unpin,
V: Unpin,
impl<K, V> UnwindSafe for TreeMap<K, V> where
K: UnwindSafe,
V: UnwindSafe,
K: UnwindSafe,
V: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
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]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,