Comment on page
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;
The iterable wrapper around value, points to previous and next key if any.
struct IterableTableCustom<K: copy, drop, store, V: store> has store
Create a new custom iterable table
public fun new<K: copy, drop, store, V: store>(): iterable_table_custom::IterableTableCustom<K, V>
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>)
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)
public fun remove<K: copy, drop, store, V: store>(table: &mut iterable_table_custom::IterableTableCustom<K, V>, key: K): V
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
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
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
Returns true if this table is empty.
public fun empty<K: copy, drop, store, V: store>(table: &iterable_table_custom::IterableTableCustom<K, V>): bool
public fun contains<K: copy, drop, store, V: store>(table: &iterable_table_custom::IterableTableCustom<K, V>, key: K): bool
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>
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>
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>)
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>)
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>)
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 modified 1yr ago