Module 0x2::table_vec
A basic scalable vector library implemented using Table
.
- Struct
TableVec
- Constants
- Function
empty
- Function
singleton
- Function
length
- Function
is_empty
- Function
borrow
- Function
push_back
- Function
borrow_mut
- Function
pop_back
- Function
destroy_empty
- Function
drop
- Function
swap
- Function
swap_remove
use 0x2::table;
use 0x2::tx_context;
Struct TableVec
struct TableVec<Element: store> has store
Fields
contents: table::Table<u64, Element>
The contents of the table vector.
Constants
const EIndexOutOfBound: u64 = 0;
const ETableNonEmpty: u64 = 1;
Function empty
Create an empty TableVec.
public fun empty<Element: store>(ctx: &mut tx_context::TxContext): table_vec::TableVec<Element>
Implementation
public fun empty<Element: store>(ctx: &mut TxContext): TableVec<Element> {
TableVec {
contents: table::new(ctx)
}
}
Function singleton
Return a TableVec of size one containing element e
.
public fun singleton<Element: store>(e: Element, ctx: &mut tx_context::TxContext): table_vec::TableVec<Element>
Implementation
Function length
Return the length of the TableVec.
public fun length<Element: store>(t: &table_vec::TableVec<Element>): u64
Function is_empty
Return if the TableVec is empty or not.
public fun is_empty<Element: store>(t: &table_vec::TableVec<Element>): bool