Module sui::vec_set
- Struct
VecSet
- Constants
- Function
empty
- Function
singleton
- Function
insert
- Function
remove
- Function
contains
- Function
size
- Function
is_empty
- Function
into_keys
- Function
from_keys
- Function
keys
- Function
get_idx_opt
- Function
get_idx
use std::option;
use std::vector;
Struct VecSet
A set data structure backed by a vector. The set is guaranteed not to contain duplicate keys. All operations are O(N) in the size of the set
- the intention of this data structure is only to provide the convenience of programming against a set API. Sets that need sorted iteration rather than insertion order iteration should be handwritten.
public struct VecSetK has copy, drop, store
Fields
Constants
This key already exists in the map
const EKeyAlreadyExists: u64 = 0;
This key does not exist in the map
const EKeyDoesNotExist: u64 = 1;
Function empty
Create an empty VecSet
public fun emptyK(): sui::vec_set::VecSet<K>
Implementation
Function singleton
Create a singleton VecSet that only contains one element.
public fun singletonK(key: K): sui::vec_set::VecSet<K>
Implementation
Function insert
Insert a key into self. Aborts if key is already present in self.
public fun insertK(self: &mut sui::vec_set::VecSet<K>, key: K)
Implementation
Function remove
Remove the entry key from self. Aborts if key is not present in self.
public fun removeK(self: &mut sui::vec_set::VecSet<K>, key: &K)
Implementation
Function contains
Return true if self contains an entry for key, false otherwise
public fun containsK(self: &sui::vec_set::VecSet<K>, key: &K): bool
Implementation
Function size
Return the number of entries in self
public fun sizeK(self: &sui::vec_set::VecSet<K>): u64
Implementation
Function is_empty
Return true if self has 0 elements, false otherwise
public fun is_emptyK(self: &sui::vec_set::VecSet<K>): bool
Implementation
Function into_keys
Unpack self into vectors of keys. The output keys are stored in insertion order, not sorted.
public fun into_keysK(self: sui::vec_set::VecSet<K>): vector<K>
Implementation
Function from_keys
Construct a new VecSet from a vector of keys. The keys are stored in insertion order (the original keys ordering) and are not sorted.
public fun from_keysK(keys: vector<K>): sui::vec_set::VecSet<K>
Implementation
Function keys
Borrow the contents of the VecSet to access content by index without unpacking. The contents are stored in insertion order, not sorted.
public fun keysK(self: &sui::vec_set::VecSet<K>): &vector<K>
Implementation
Function get_idx_opt
Find the index of key in self. Return None if key is not in self. Note that keys are stored in insertion order, not sorted.
fun get_idx_optK(self: &sui::vec_set::VecSet<K>, key: &K): std::option::Option<u64>
Implementation
Function get_idx
Find the index of key in self. Aborts if key is not in self. Note that map entries are stored in insertion order, not sorted.
fun get_idxK(self: &sui::vec_set::VecSet<K>, key: &K): u64