Struct near_sdk::collections::UnorderedSet [−][src]
An iterable implementation of a set that stores its content directly on the trie.
Implementations
impl<T> UnorderedSet<T>
[src]
pub fn len(&self) -> u64
[src]
Returns the number of elements in the set, also referred to as its size.
pub fn is_empty(&self) -> bool
[src]
Returns true
if the set 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, element_raw: &[u8]) -> bool
[src]
Adds a value to the set.
If the set did not have this value present, true
is returned.
If the set did have this value present, false
is returned.
pub fn remove_raw(&mut self, element_raw: &[u8]) -> bool
[src]
Removes a value from the set. Returns whether the value was present in the set.
impl<T> UnorderedSet<T> where
T: BorshSerialize + BorshDeserialize,
[src]
T: BorshSerialize + BorshDeserialize,
pub fn contains(&self, element: &T) -> bool
[src]
Returns true if the set contains an element.
pub fn remove(&mut self, element: &T) -> bool
[src]
Removes a value from the set. Returns whether the value was present in the set.
pub fn insert(&mut self, element: &T) -> bool
[src]
Adds a value to the set.
If the set did not have this value present, true
is returned.
If the set did have this value present, false
is returned.
pub fn clear(&mut self)
[src]
Clears the map, removing all elements.
pub fn to_vec(&self) -> Vec<T>
[src]
Copies elements into an std::vec::Vec
.
pub fn iter<'a>(&'a self) -> impl Iterator<Item = T> + 'a
[src]
Iterate over deserialized elements.
pub fn extend<IT: IntoIterator<Item = T>>(&mut self, iter: IT)
[src]
pub fn as_vector(&self) -> &Vector<T>
[src]
Returns a view of elements as a vector. It’s sometimes useful to have random access to the elements.
Trait Implementations
impl<T> BorshDeserialize for UnorderedSet<T> where
Vec<u8>: BorshDeserialize,
Vector<T>: BorshDeserialize,
[src]
Vec<u8>: BorshDeserialize,
Vector<T>: BorshDeserialize,
fn deserialize(buf: &mut &[u8]) -> Result<Self, Error>
[src]
pub fn try_from_slice(v: &[u8]) -> Result<Self, Error>
[src]
pub fn is_u8() -> bool
[src]
impl<T> BorshSerialize for UnorderedSet<T> where
Vec<u8>: BorshSerialize,
Vector<T>: BorshSerialize,
[src]
Vec<u8>: BorshSerialize,
Vector<T>: BorshSerialize,
Auto Trait Implementations
impl<T> RefUnwindSafe for UnorderedSet<T> where
T: RefUnwindSafe,
T: RefUnwindSafe,
impl<T> Send for UnorderedSet<T> where
T: Send,
T: Send,
impl<T> Sync for UnorderedSet<T> where
T: Sync,
T: Sync,
impl<T> Unpin for UnorderedSet<T> where
T: Unpin,
T: Unpin,
impl<T> UnwindSafe for UnorderedSet<T> where
T: UnwindSafe,
T: 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,
pub 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.
pub 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>,