[−]Struct near_sdk::collections::Set
An iterable implementation of a set that stores its content directly on the trie.
Methods
impl<T> Set<T>
[src]
pub fn len(&self) -> u64
[src]
Returns the number of elements in the set, also referred to as its size.
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. Note, the elements that have the same hash value are undistinguished by
the implementation.
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> Set<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. Note, the elements 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<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 Set<T> where
Vec<u8>: BorshDeserialize,
Vector<T>: BorshDeserialize,
[src]
Vec<u8>: BorshDeserialize,
Vector<T>: 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<T> BorshSerialize for Set<T> where
Vec<u8>: BorshSerialize,
Vector<T>: BorshSerialize,
[src]
Vec<u8>: BorshSerialize,
Vector<T>: 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<T> Default for Set<T>
[src]
Auto Trait Implementations
impl<T> RefUnwindSafe for Set<T> where
T: RefUnwindSafe,
T: RefUnwindSafe,
impl<T> Send for Set<T> where
T: Send,
T: Send,
impl<T> Sync for Set<T> where
T: Sync,
T: Sync,
impl<T> Unpin for Set<T> where
T: Unpin,
T: Unpin,
impl<T> UnwindSafe for Set<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,
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>,