pub struct Vector<T> { /* private fields */ }
Expand description

An iterable implementation of vector that stores its content on the trie. Uses the following map: index -> element.

Implementations

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

Returns true if the vector contains no elements.

Create new vector with zero elements. Use id as a unique identifier on the trie.

Examples
use near_sdk::collections::Vector;
let mut set: Vector<u32> = Vector::new(b"m");

Helper utility to be able to easily migrate to the new Vector implementation.

This new Vector’s API matches the Rust Vec API more closely and has a caching layer to avoid reading/writing redundant times to storage.

Returns the serialized element by index or None if it is not present.

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.

Appends a serialized element to the back of the collection.

Removes the last element from a vector and returns it without deserializing, or None if it is empty.

Inserts a serialized element at index, returns a serialized evicted element.

Panics

If index is out of bounds.

Iterate over raw serialized elements.

Extends vector from the given collection of serialized elements.

Removes all elements from the collection.

Appends an element to the back of the collection.

Extends vector from the given collection.

Returns the element by index or None if it is not present.

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.

Removes the last element from a vector and returns it, or None if it is empty.

Iterate over deserialized elements.

Inserts a element at index, returns an evicted element.

Panics

If index is out of bounds.

Trait Implementations

Deserializes this instance from a given slice of bytes. Updates the buffer to point at the remaining bytes. Read more
Deserialize this instance from a slice of bytes.
Serialize this instance into a vector of bytes.
Formats the value using the given formatter. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Should always be Self
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.