pub struct RefList<T> { /* private fields */ }
Expand description

List that tracks references and indices.

Implementations§

source§

impl<T> RefList<T>

source

pub fn new() -> Self

New empty list.

source

pub fn push(&mut self, t: T) -> EntryRef<T>

Push new element in the list.

Returns refernce tracking entry.

source

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.

source

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.

source

pub fn begin_insert_after<F>(&mut self, f: F) -> InsertTransaction<'_, T>
where F: FnMut(&T) -> bool,

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.

source

pub fn begin_insert_not_until<F>(&mut self, f: F) -> InsertTransaction<'_, T>
where F: FnMut(&T) -> bool,

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.

source

pub fn get(&self, idx: usize) -> Option<EntryRef<T>>

Get entry with index (checked).

Can return None when index out of bounts.

source

pub fn delete(&mut self, indices: &[usize])

Delete several items.

source

pub fn delete_one(&mut self, index: usize)

Delete one item.

source

pub fn from_slice(list: &[T]) -> Self
where T: Clone,

Initialize from slice.

Slice members are cloned.

source

pub fn len(&self) -> usize

Length of the list.

source

pub fn is_empty(&self) -> bool

Returns true iff len == 0.

source

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.

source

pub fn get_ref(&self, idx: usize) -> &EntryRef<T>

Get reference to entry by index.

Will panic if index out of bounds.

source

pub fn iter(&self) -> Iter<'_, EntryRef<T>>

Iterate through entries.

Trait Implementations§

source§

impl<T: Debug> Debug for RefList<T>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<T> Default for RefList<T>

source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<T> !RefUnwindSafe for RefList<T>

§

impl<T> !Send for RefList<T>

§

impl<T> !Sync for RefList<T>

§

impl<T> Unpin for RefList<T>

§

impl<T> !UnwindSafe for RefList<T>

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.