Skip to content

QuaternaryList class

Attributes: [DefaultMember("Item")] [DebuggerDisplay("QuaternaryList: {Count}")]

Defined in

Namespace: ReactiveList.Reactive.Collections Assembly: ReactiveList.Reactive.dll Full name: ReactiveList.Reactive.Collections.QuaternaryList<T> Modifiers: public sealed

Summary

View source (opens in a new tab)

        Represents a high-performance, thread-safe list that partitions its elements across four internal shards for
        efficient concurrent access and batch operations. Supports secondary indexing for fast lookups by custom keys.

Applies to

net11.0, net10.0, net47, net471, net472, net48, net481

Class hierarchy
classDiagram
class QuaternaryList~T~
class IQuaternaryList~T~ {
    <>
}
IQuaternaryList~T~ <|.. QuaternaryList~T~
class ICollection~T~ {
    <>
}
ICollection~T~ <|.. QuaternaryList~T~
class IEnumerable~T~ {
    <>
}
IEnumerable~T~ <|.. QuaternaryList~T~
class IEnumerable {
    <>
}
IEnumerable <|.. QuaternaryList~T~
class IReactiveSource~T~ {
    <>
}
IReactiveSource~T~ <|.. QuaternaryList~T~
class INotifyCollectionChanged {
    <>
}
INotifyCollectionChanged <|.. QuaternaryList~T~
class IDisposable {
    <>
}
IDisposable <|.. QuaternaryList~T~
class IVersionedSnapshotSource~T~ {
    <>
}
IVersionedSnapshotSource~T~ <|.. QuaternaryList~T~
class INotifyPropertyChanged {
    <>
}
INotifyPropertyChanged <|.. QuaternaryList~T~
class IReactiveSourceWithOptions {
    <>
}
IReactiveSourceWithOptions <|.. QuaternaryList~T~

Implements: IQuaternaryList, ICollection (opens in a new tab), IEnumerable (opens in a new tab), IEnumerable (opens in a new tab), IReactiveSource, INotifyCollectionChanged (opens in a new tab), IDisposable (opens in a new tab), IVersionedSnapshotSource, INotifyPropertyChanged (opens in a new tab), IReactiveSourceWithOptions

Remarks

QuaternaryList{T} is optimized for scenarios involving frequent additions, removals, and batch operations on large datasets. Internally, items are distributed across four shards, each guarded by its own reader-writer lock, to reduce contention and improve parallelism. Operations that touch several shards take the locks in ascending shard order. Change notifications are queued while the shard lock is still held, so observers see changes in the order they happened, and are delivered by a single background reader. After Dispose every operation that reads or writes items throws ObjectDisposedException (opens in a new tab). The collection is not read-only and supports dynamic growth. Secondary indices can be added to enable efficient lookups by arbitrary keys. All public methods are thread-safe. The list may hold equal items more than once; an index returns one entry per copy. Enumeration, ToArray and Snapshot work on a point-in-time copy, so a consumer can call back into the list while enumerating. Direct index-based operations (such as Insert, RemoveAt, or setting by index) are not supported and will throw exceptions; use Add, Remove, or batch methods instead. The callbacks given to Edit run while every shard is locked and must not call back into the list.

Constructors

NameSummary
.ctorInitializes a new instance of the QuaternaryList class.

Properties

NameSummary
CountGets the total number of items contained in all shards.
IsReadOnlyGets a value indicating whether the collection is read-only.
StreamGets an observable sequence that emits cache change notifications as they occur.
VersionedStreamGets an observable of change notifications, each paired with the version the change produced.
OptionsGets the options that apply for the lifetime of the source.
IsDisposedGets a value indicating whether the object has been disposed.
VersionGets the current version number of the collection, which is incremented on each modification.
this[]Gets or sets the element at the specified index.

Methods

NameSummary
AddAdds the specified item to the collection.
RemoveRemoves the specified item from the collection.
ClearRemoves all items from the cache.
DeferNotificationsDefers change notifications until the last active deferral is disposed.
DisposeReleases all resources used by the current instance.
AddRangeAdds the elements of the specified collection to the current set.
RemoveRangeRemoves all elements in the specified collection from the current set.
RemoveManyRemoves all elements that match the specified predicate from the collection.
EditPerforms a batch edit operation on the collection, ensuring only a single change notification is emitted.
ReplaceAllReplaces all existing items with new items atomically, emitting a single change notification.
AddIndexAdds a secondary index to enable efficient lookups based on a specified key selector.
GetItemsBySecondaryIndexRetrieves all entities of type T that match the specified key in the given secondary index.
ItemMatchesSecondaryIndexDetermines whether the specified item matches the given key in the specified secondary index.
ContainsDetermines whether the collection contains a specific value.
CopyToCopies the elements of the collection to an array.
ToArrayReturns an array containing all elements in the collection.
CopyVersionedCopies every item and reports the version of that copy.
GetEnumeratorReturns an enumerator over a point-in-time copy of the collection.
SnapshotCreates a snapshot of the current items as a read-only list.

Events

NameSummary
CollectionChangedOccurs when the collection changes.
PropertyChangedOccurs when a property value changes.
Inherited members