Struct gear_pwasm_utils::RefList
source · pub struct RefList<T> { /* private fields */ }
Expand description
List that tracks references and indices.
Implementations§
source§impl<T> RefList<T>
impl<T> RefList<T>
sourcepub fn push(&mut self, t: T) -> EntryRef<T>
pub fn push(&mut self, t: T) -> EntryRef<T>
Push new element in the list.
Returns refernce tracking entry.
sourcepub fn begin_delete(&mut self) -> DeleteTransaction<'_, T>
pub fn begin_delete(&mut self) -> DeleteTransaction<'_, T>
Start deleting.
Start deleting some entries in the list. Returns transaction that can be populated with number of removed entries. When transaction is finailized, all entries are deleted and internal indices of other entries are updated.
sourcepub fn begin_insert(&mut self, at: usize) -> InsertTransaction<'_, T>
pub fn begin_insert(&mut self, at: usize) -> InsertTransaction<'_, T>
Start inserting.
Start inserting some entries in the list at he designated position. Returns transaction that can be populated with some entries. When transaction is finailized, all entries are inserted and internal indices of other entries might be updated.
sourcepub fn begin_insert_after<F>(&mut self, f: F) -> InsertTransaction<'_, T>
pub fn begin_insert_after<F>(&mut self, f: F) -> InsertTransaction<'_, T>
Start inserting after the condition first matches (or at the end).
Start inserting some entries in the list at he designated position. Returns transaction that can be populated with some entries. When transaction is finailized, all entries are inserted and internal indices of other entries might be updated.
sourcepub fn begin_insert_not_until<F>(&mut self, f: F) -> InsertTransaction<'_, T>
pub fn begin_insert_not_until<F>(&mut self, f: F) -> InsertTransaction<'_, T>
Start inserting after the condition first no longer true (or at the end).
Start inserting some entries in the list at he designated position. Returns transaction that can be populated with some entries. When transaction is finailized, all entries are inserted and internal indices of other entries might be updated.
sourcepub fn get(&self, idx: usize) -> Option<EntryRef<T>>
pub fn get(&self, idx: usize) -> Option<EntryRef<T>>
Get entry with index (checked).
Can return None when index out of bounts.
sourcepub fn delete_one(&mut self, index: usize)
pub fn delete_one(&mut self, index: usize)
Delete one item.
sourcepub fn from_slice(list: &[T]) -> Selfwhere
T: Clone,
pub fn from_slice(list: &[T]) -> Selfwhere
T: Clone,
Initialize from slice.
Slice members are cloned.
sourcepub fn clone_ref(&self, idx: usize) -> EntryRef<T>
pub fn clone_ref(&self, idx: usize) -> EntryRef<T>
Clone entry (reference counting object to item) by index.
Will panic if index out of bounds.