Struct near_sdk::collections::UnorderedMap[][src]

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

An iterable implementation of a map that stores its content directly on the trie.

Implementations

impl<K, V> UnorderedMap<K, V>[src]

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

Returns the number of elements in the map, also referred to as its size.

pub fn is_empty(&self) -> bool[src]

Returns true if the map contains no elements.

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

Create new map with zero elements. Use id as a unique identifier.

pub fn insert_raw(
    &mut self,
    key_raw: &[u8],
    value_raw: &[u8]
) -> Option<Vec<u8>>
[src]

Inserts a serialized key-value pair into the map. If the map did not have this key present, None is returned. Otherwise returns a serialized value. Note, the keys that have the same hash value are undistinguished by the implementation.

pub fn remove_raw(&mut self, key_raw: &[u8]) -> Option<Vec<u8>>[src]

Removes a serialized key from the map, returning the serialized value at the key if the key was previously in the map.

impl<K, V> UnorderedMap<K, V> where
    K: BorshSerialize + BorshDeserialize,
    V: BorshSerialize + BorshDeserialize
[src]

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

Returns the value corresponding to the key.

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

Removes a key from the map, returning the value at the key if the key was previously in the map.

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

Inserts a key-value pair into the map. If the map did not have this key present, None is returned. Otherwise returns a value. Note, the keys that have the same hash value are undistinguished by the implementation.

pub fn clear(&mut self)[src]

Clears the map, removing all elements.

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

Copies elements into an std::vec::Vec.

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

An iterator visiting all keys. The iterator element type is K.

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

An iterator visiting all values. The iterator element type is V.

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

Iterate over deserialized keys and values.

pub fn extend<IT: IntoIterator<Item = (K, V)>>(&mut self, iter: IT)[src]

pub fn keys_as_vector(&self) -> &Vector<K>[src]

Returns a view of keys as a vector. It’s sometimes useful to have random access to the keys.

pub fn values_as_vector(&self) -> &Vector<V>[src]

Returns a view of values as a vector. It’s sometimes useful to have random access to the values.

Trait Implementations

impl<K, V> BorshDeserialize for UnorderedMap<K, V> where
    Vec<u8>: BorshDeserialize,
    Vector<K>: BorshDeserialize,
    Vector<V>: BorshDeserialize
[src]

impl<K, V> BorshSerialize for UnorderedMap<K, V> where
    Vec<u8>: BorshSerialize,
    Vector<K>: BorshSerialize,
    Vector<V>: BorshSerialize
[src]

Auto Trait Implementations

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

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

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

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

impl<K, V> UnwindSafe for UnorderedMap<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.