Skip to main content

ChangeAwareList

Struct ChangeAwareList 

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

A list that records its changes until they are captured (ChangeAwareList<T>), batching consecutive insertions and removals into ranges as upstream does.

Implementations§

Source§

impl<T: Clone + PartialEq> ChangeAwareList<T>

Source

pub fn new() -> Self

An empty list (ChangeAwareList(int capacity = -1)).

Source

pub fn with_capacity(capacity: usize) -> Self

An empty list with room for capacity items.

Source

pub fn from_items(items: Vec<T>) -> Self

A list of the items, whose first change adds them (ChangeAwareList(IEnumerable<T>)).

Source

pub fn from_list(list: &ChangeAwareList<T>, copy_changes: bool) -> Self

A copy of list, with its changes or without (ChangeAwareList(ChangeAwareList<T>, bool)).

Source

pub fn count(&self) -> usize

The number of items (Count).

Source

pub fn is_empty(&self) -> bool

Source

pub fn items(&self) -> &[T]

The items.

Source

pub fn get(&self, index: usize) -> &T

The item at index (the indexer’s getter).

Source

pub fn set(&mut self, index: usize, item: T)

Replaces the item at index (the indexer’s setter, SetItem).

Source

pub fn add(&mut self, item: T)

Adds an item at the end (Add).

Source

pub fn capture_changes(&mut self) -> ChangeSet<T>

The changes since the last capture, and a clean slate (CaptureChanges): removals that emptied the list are reported as one Clear.

Source

pub fn clear(&mut self)

Removes every item (Clear).

Source

pub fn contains(&self, item: &T) -> bool

Whether the list has item (Contains).

Source

pub fn index_of(&self, item: &T) -> Option<usize>

The index of item (IndexOf).

Source

pub fn index_of_with( &self, item: &T, comparer: &dyn Fn(&T, &T) -> bool, ) -> Option<usize>

The index of item by comparer (IndexOf(T, IEqualityComparer<T>)).

Source

pub fn insert(&mut self, index: usize, item: T)

Inserts an item (Insert).

§Panics

When index is beyond the end (ArgumentException).

Source

pub fn move_item(&mut self, item: &T, destination: usize)

Moves item to destination (Move(T, int)).

Source

pub fn refresh_with(&mut self, item: T, index: usize)

Replaces the item at index with item and reports a refresh (Refresh(T, int)).

Source

pub fn refresh(&mut self, item: &T) -> bool

Reports a refresh of item; false when it is not in the list (Refresh(T)).

Source

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

Reports a refresh of the item at index (RefreshAt).

Source

pub fn remove(&mut self, item: &T) -> bool

Removes item; false when it is not in the list (Remove(T)).

Source

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

Removes the item at index (RemoveAt).

Source§

impl<T: Clone + PartialEq> ChangeAwareList<T>

Source

pub fn add_range(&mut self, items: Vec<T>)

Adds the items at the end (AddRange).

Source

pub fn remove_range(&mut self, index: usize, count: usize)

Removes count items from index (RemoveRange).

Trait Implementations§

Source§

impl<T: Clone + PartialEq> Default for ChangeAwareList<T>

Source§

fn default() -> Self

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

impl<T: Clone + PartialEq> IExtendedList<T> for ChangeAwareList<T>

Source§

fn insert_range(&mut self, items: Vec<T>, index: usize)

Inserts the items at index (InsertRange).
Source§

fn move_index(&mut self, original: usize, destination: usize)

Moves the item at original to destination (Move(int, int)).
Source§

impl<T: Clone + PartialEq> IList<T> for ChangeAwareList<T>

Source§

fn count(&self) -> usize

The number of items (Count).
Source§

fn get(&self, index: usize) -> T

The item at index (the indexer’s getter).
Source§

fn set(&mut self, index: usize, item: T)

Replaces the item at index (the indexer’s setter).
Source§

fn insert(&mut self, index: usize, item: T)

Inserts an item (Insert).
Source§

fn remove_at(&mut self, index: usize)

Removes the item at index (RemoveAt).
Source§

fn clear(&mut self)

Removes every item (Clear).
Source§

fn add(&mut self, item: T)

Adds an item at the end (Add).
Source§

fn index_of(&self, item: &T) -> Option<usize>

The index of item (IndexOf).
Source§

fn remove(&mut self, item: &T) -> bool

Removes item; false when it is not in the list (Remove).
Source§

fn add_range(&mut self, items: Vec<T>)

Adds the items at the end (ListEx.AddRange): one by one unless the list adds ranges.
Source§

fn add_or_insert_range(&mut self, items: Vec<T>, index: Option<usize>)

Inserts the items at index, or adds them without an index (ListEx.AddOrInsertRange): in reverse order at the index unless the list inserts ranges, as upstream does.
Source§

fn remove_range(&mut self, index: usize, count: usize)

Removes count items from index (ListEx.RemoveRange). Read more
Source§

fn supports_ranges(&self) -> bool

Whether the list removes ranges at once (List<T> or IExtendedList<T>).
Source§

fn move_item(&mut self, original: usize, destination: usize)

Moves the item at original to destination (the Moved case of ListEx.Clone).
Source§

fn refresh_at(&mut self, index: usize, _item: T)

Reports a refresh of the item at index (the Refresh case of ListEx.Clone): the item is removed and inserted again unless the list reports refreshes.
Source§

fn index_of_with( &self, item: &T, comparer: &dyn Fn(&T, &T) -> bool, ) -> Option<usize>

The index of item by comparer (ListEx.IndexOf(IEnumerable, T, IEqualityComparer)).

Auto Trait Implementations§

§

impl<T> !RefUnwindSafe for ChangeAwareList<T>

§

impl<T> !Send for ChangeAwareList<T>

§

impl<T> !Sync for ChangeAwareList<T>

§

impl<T> !UnwindSafe for ChangeAwareList<T>

§

impl<T> Freeze for ChangeAwareList<T>
where Vec<T>: Freeze, Vec<Change<T>>: Freeze, Option<Box<dyn ChangeAwareListHooks<T>>>: Freeze,

§

impl<T> Unpin for ChangeAwareList<T>
where Vec<T>: Unpin, Vec<Change<T>>: Unpin, Option<Box<dyn ChangeAwareListHooks<T>>>: Unpin,

§

impl<T> UnsafeUnpin for ChangeAwareList<T>
where Vec<T>: UnsafeUnpin, Vec<Change<T>>: UnsafeUnpin, Option<Box<dyn ChangeAwareListHooks<T>>>: UnsafeUnpin,

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>,

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

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

Source§

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.