helpers::iterable_table_custom
Module 0xc0ded0c0::iterable_table_custom
0xc0ded0c0::iterable_table_custom
module helpers::iterable_table_custom
helpers::iterable_table_custom
This module is a wrapper around aptos_std::iterable_table
. This allows a quick change in data structure that Tortuga uses, in case iterable_table
is deemed to be not suitable at some point.
use 0x1::option;
use 0xc0ded0c0::iterable_table;
Struct IterableTableCustom
IterableTableCustom
The iterable wrapper around value, points to previous and next key if any.
struct IterableTableCustom<K: copy, drop, store, V: store> has store
Function new
new
Create a new custom iterable table
public fun new<K: copy, drop, store, V: store>(): iterable_table_custom::IterableTableCustom<K, V>
Function destroy_empty
destroy_empty
Destroy a table. The table must be empty to succeed.
public fun destroy_empty<K: copy, drop, store, V: store>(table: iterable_table_custom::IterableTableCustom<K, V>)
Function add
add
Add a new entry to the table. Aborts if an entry for this key already exists.
public fun add<K: copy, drop, store, V: store>(table: &mut iterable_table_custom::IterableTableCustom<K, V>, key: K, val: V)
Function remove
remove
Remove from table
and return the value which key
maps to. Aborts if there is no entry for key
.
public fun remove<K: copy, drop, store, V: store>(table: &mut iterable_table_custom::IterableTableCustom<K, V>, key: K): V
Function borrow
borrow
Acquire an immutable reference to the value which key
maps to. Aborts if there is no entry for key
.
public fun borrow<K: copy, drop, store, V: store>(table: &iterable_table_custom::IterableTableCustom<K, V>, key: K): &V
Function borrow_mut
borrow_mut
Acquire a mutable reference to the value which key
maps to. Aborts if there is no entry for key
.
public fun borrow_mut<K: copy, drop, store, V: store>(table: &mut iterable_table_custom::IterableTableCustom<K, V>, key: K): &mut V
Function length
length
Returns the length of the table, i.e. the number of entries.
public fun length<K: copy, drop, store, V: store>(table: &iterable_table_custom::IterableTableCustom<K, V>): u64
Function empty
empty
Returns true if this table is empty.
public fun empty<K: copy, drop, store, V: store>(table: &iterable_table_custom::IterableTableCustom<K, V>): bool
Function contains
contains
Returns true iff table
contains an entry for key
.
public fun contains<K: copy, drop, store, V: store>(table: &iterable_table_custom::IterableTableCustom<K, V>, key: K): bool
Function head_key
head_key
Iterable API. Returns the key of the head for iteration.
public fun head_key<K: copy, drop, store, V: store>(table: &iterable_table_custom::IterableTableCustom<K, V>): option::Option<K>
Function tail_key
tail_key
Returns the key of the tail for iteration.
public fun tail_key<K: copy, drop, store, V: store>(table: &iterable_table_custom::IterableTableCustom<K, V>): option::Option<K>
Function borrow_iter
borrow_iter
Acquire an immutable reference to the IterableValue which key
maps to. Aborts if there is no entry for key
.
public fun borrow_iter<K: copy, drop, store, V: store>(table: &iterable_table_custom::IterableTableCustom<K, V>, key: K): (&V, option::Option<K>, option::Option<K>)
Function borrow_iter_mut
borrow_iter_mut
Acquire a mutable reference to the value and previous/next key which key
maps to. Aborts if there is no entry for key
.
public fun borrow_iter_mut<K: copy, drop, store, V: store>(table: &mut iterable_table_custom::IterableTableCustom<K, V>, key: K): (&mut V, option::Option<K>, option::Option<K>)
Function remove_iter
remove_iter
Remove from table
and return the value and previous/next key which key
maps to. Aborts if there is no entry for key
.
public fun remove_iter<K: copy, drop, store, V: store>(table: &mut iterable_table_custom::IterableTableCustom<K, V>, key: K): (V, option::Option<K>, option::Option<K>)
Function append
append
Remove all items from v2 and append to v1.
public fun append<K: copy, drop, store, V: store>(v1: &mut iterable_table_custom::IterableTableCustom<K, V>, v2: &mut iterable_table_custom::IterableTableCustom<K, V>)
Last updated