[−][src]Struct near_sdk::collections::Vector
An iterable implementation of vector that stores its content on the trie. Uses the following map: index -> element.
Implementations
impl<T> Vector<T>
[src]
pub fn len(&self) -> u64
[src]
Returns the number of elements in the vector, also referred to as its size.
pub fn is_empty(&self) -> bool
[src]
Returns true
if the vector contains no elements.
pub fn new(id: Vec<u8>) -> Self
[src]
Create new vector with zero elements. Use id
as a unique identifier on the trie.
pub fn get_raw(&self, index: u64) -> Option<Vec<u8>>
[src]
Returns the serialized element by index or None
if it is not present.
pub fn swap_remove_raw(&mut self, index: u64) -> Vec<u8>
[src]
Removes an element from the vector and returns it in serialized form.
The removed element is replaced by the last element of the vector.
Does not preserve ordering, but is O(1)
.
Panics
Panics if index
is out of bounds.
pub fn push_raw(&mut self, raw_element: &[u8])
[src]
Appends a serialized element to the back of the collection.
pub fn pop_raw(&mut self) -> Option<Vec<u8>>
[src]
Removes the last element from a vector and returns it without deserializing, or None
if it is empty.
pub fn replace_raw(&mut self, index: u64, raw_element: &[u8]) -> Vec<u8>
[src]
Inserts a serialized element at index
, returns a serialized evicted element.
Panics
If index
is out of bounds.
pub fn iter_raw<'a>(&'a self) -> impl Iterator<Item = Vec<u8>> + 'a
[src]
Iterate over raw serialized elements.
pub fn extend_raw<IT: IntoIterator<Item = Vec<u8>>>(&mut self, iter: IT)
[src]
Extends vector from the given collection of serialized elements.
impl<T> Vector<T>
[src]
impl<T> Vector<T> where
T: BorshSerialize,
[src]
T: BorshSerialize,
pub fn push(&mut self, element: &T)
[src]
Appends an element to the back of the collection.
pub fn extend<IT: IntoIterator<Item = T>>(&mut self, iter: IT)
[src]
Extends vector from the given collection.
impl<T> Vector<T> where
T: BorshDeserialize,
[src]
T: BorshDeserialize,
pub fn get(&self, index: u64) -> Option<T>
[src]
Returns the element by index or None
if it is not present.
pub fn swap_remove(&mut self, index: u64) -> T
[src]
Removes an element from the vector and returns it.
The removed element is replaced by the last element of the vector.
Does not preserve ordering, but is O(1)
.
Panics
Panics if index
is out of bounds.
pub fn pop(&mut self) -> Option<T>
[src]
Removes the last element from a vector and returns it, or None
if it is empty.
pub fn iter<'a>(&'a self) -> impl Iterator<Item = T> + 'a
[src]
Iterate over deserialized elements.
pub fn to_vec(&self) -> Vec<T>
[src]
impl<T> Vector<T> where
T: BorshSerialize + BorshDeserialize,
[src]
T: BorshSerialize + BorshDeserialize,
Trait Implementations
impl<T> BorshDeserialize for Vector<T> where
u64: BorshDeserialize,
Vec<u8>: BorshDeserialize,
[src]
u64: BorshDeserialize,
Vec<u8>: 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 Vector<T> where
u64: BorshSerialize,
Vec<u8>: BorshSerialize,
[src]
u64: BorshSerialize,
Vec<u8>: 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: Debug> Debug for Vector<T>
[src]
impl<T> Default for Vector<T>
[src]
Auto Trait Implementations
impl<T> RefUnwindSafe for Vector<T> where
T: RefUnwindSafe,
T: RefUnwindSafe,
impl<T> Send for Vector<T> where
T: Send,
T: Send,
impl<T> Sync for Vector<T> where
T: Sync,
T: Sync,
impl<T> Unpin for Vector<T> where
T: Unpin,
T: Unpin,
impl<T> UnwindSafe for Vector<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>,