Table of Contents

Class SwiftObservableList<T>

Namespace
SwiftCollections.Observable
Assembly
SwiftCollections.dll

Represents an observable extension of the high-performance SwiftList<T>. Notifies listeners of changes to its items and structure for reactive programming scenarios.

[JsonConverter(typeof(StateJsonConverterFactory))]
[MemoryPackable(GenerateType.Object)]
public class SwiftObservableList<T> : SwiftList<T>, ISwiftCloneable<T>, IList<T>, ICollection<T>, IEnumerable<T>, IList, ICollection, IEnumerable, IMemoryPackable<SwiftList<T>>, IStateBacked<SwiftArrayState<T>>, INotifyPropertyChanged, INotifyCollectionChanged, IMemoryPackable<SwiftObservableList<T>>, IMemoryPackFormatterRegister

Type Parameters

T

The type of elements in the list.

Inheritance
SwiftObservableList<T>
Implements
IMemoryPackable<SwiftList<T>>
IStateBacked<SwiftArrayState<T>>
IMemoryPackable<SwiftObservableList<T>>
IMemoryPackFormatterRegister
Inherited Members
Extension Methods

Remarks

MemoryPack GenerateType: Object

SwiftCollections.SwiftArrayState<T> State

Constructors

SwiftObservableList()

Initializes a new instance of the SwiftObservableList<T> class.

public SwiftObservableList()

SwiftObservableList(SwiftArrayState<T>)

Initializes a new instance of the SwiftObservableList<T> class with the specified SwiftArrayState<T>.

[MemoryPackConstructor]
public SwiftObservableList(SwiftArrayState<T> state)

Parameters

state SwiftArrayState<T>

The state containing the internal array, count, offset, and version for initialization.

SwiftObservableList(IEnumerable<T>)

Initializes a new instance of the SwiftObservableList<T> class that contains elements copied from the specified collection.

public SwiftObservableList(IEnumerable<T> collection)

Parameters

collection IEnumerable<T>

SwiftObservableList(int)

Initializes a new instance of the SwiftObservableList<T> class with the specified initial capacity.

public SwiftObservableList(int capacity)

Parameters

capacity int

Properties

this[int]

Sets or gets the element at the specified index. Raises collection change notifications on modification.

[JsonIgnore]
[MemoryPackIgnore]
public T this[int index] { get; set; }

Parameters

index int

Property Value

T

Methods

Add(T)

Adds an element to the end of the list. Raises collection and property change notifications.

public override void Add(T item)

Parameters

item T

AddRange(IEnumerable<T>)

Adds the elements of the specified collection to the end of the current collection.

public override void AddRange(IEnumerable<T> items)

Parameters

items IEnumerable<T>

The collection whose elements should be added to the end of the collection. Cannot be null.

Remarks

Known-count sources reserve capacity before enumeration while preserving per-item notifications.

AddRange(ReadOnlySpan<T>)

Adds the elements of the specified span to the end of the list. Raises collection and property change notifications for each added item.

public override void AddRange(ReadOnlySpan<T> items)

Parameters

items ReadOnlySpan<T>

AddRange(T[])

Adds the elements of the specified array to the end of the list. Raises collection and property change notifications for each added item.

public override void AddRange(T[] items)

Parameters

items T[]

Clear()

Clears all elements from the list. Raises a reset collection change notification.

public override void Clear()

Insert(int, T)

Inserts an element into the list at the specified index. Raises collection and property change notifications.

public override void Insert(int index, T item)

Parameters

index int
item T

OnCollectionChanged(NotifyCollectionChangedEventArgs)

Raises the CollectionChanged event for the specified action and items.

protected virtual void OnCollectionChanged(NotifyCollectionChangedEventArgs args)

Parameters

args NotifyCollectionChangedEventArgs

OnPropertyChanged(string)

Raises the PropertyChanged event.

protected virtual void OnPropertyChanged(string propertyName)

Parameters

propertyName string

The name of the property that changed.

Remove(T)

Removes the first occurrence of a specific object from the list. Raises collection and property change notifications.

public override bool Remove(T item)

Parameters

item T

Returns

bool

RemoveAll(Predicate<T>)

Removes all elements from the collection that match the conditions defined by the specified predicate.

public override int RemoveAll(Predicate<T> match)

Parameters

match Predicate<T>

The delegate that defines the conditions of the elements to remove. Cannot be null.

Returns

int

The number of elements removed from the collection.

Remarks

Raises a collection changed event with the Reset action and notifies property changes if any elements are removed. This method is useful when you need to remove multiple items based on a condition and notify observers of the change.

RemoveAt(int)

Removes the element at the specified index. Raises collection and property change notifications.

public override void RemoveAt(int index)

Parameters

index int

Events

CollectionChanged

Raised when the list's collection is modified.

public event NotifyCollectionChangedEventHandler? CollectionChanged

Event Type

NotifyCollectionChangedEventHandler

PropertyChanged

Raised when a property on the list changes.

public event PropertyChangedEventHandler? PropertyChanged

Event Type

PropertyChangedEventHandler