Skip to content

QuaternaryDictionary class

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

Defined in

Namespace: ReactiveList.Reactive.Collections Assembly: ReactiveList.Reactive.dll Full name: ReactiveList.Reactive.Collections.QuaternaryDictionary<T1, T2> Modifiers: public sealed

Summary

View source (opens in a new tab)

        Represents a thread-safe, sharded dictionary that distributes key-value pairs across four internal partitions for
        improved concurrency and scalability.

Applies to

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

Class hierarchy
classDiagram
class QuaternaryDictionary~T1,T2~
class IQuaternaryDictionary~TKey, TValue~ {
    <>
}
IQuaternaryDictionary~TKey, TValue~ <|.. QuaternaryDictionary~T1,T2~
class IDictionary~TKey, TValue~ {
    <>
}
IDictionary~TKey, TValue~ <|.. QuaternaryDictionary~T1,T2~
class ICollection~KeyValuePair~TKey, TValue~~ {
    <>
}
ICollection~KeyValuePair~TKey, TValue~~ <|.. QuaternaryDictionary~T1,T2~
class IEnumerable~KeyValuePair~TKey, TValue~~ {
    <>
}
IEnumerable~KeyValuePair~TKey, TValue~~ <|.. QuaternaryDictionary~T1,T2~
class IEnumerable {
    <>
}
IEnumerable <|.. QuaternaryDictionary~T1,T2~
class IReactiveSource~KeyValuePair~TKey, TValue~~ {
    <>
}
IReactiveSource~KeyValuePair~TKey, TValue~~ <|.. QuaternaryDictionary~T1,T2~
class INotifyCollectionChanged {
    <>
}
INotifyCollectionChanged <|.. QuaternaryDictionary~T1,T2~
class IDisposable {
    <>
}
IDisposable <|.. QuaternaryDictionary~T1,T2~
class IVersionedSnapshotSource~KeyValuePair~TKey, TValue~~ {
    <>
}
IVersionedSnapshotSource~KeyValuePair~TKey, TValue~~ <|.. QuaternaryDictionary~T1,T2~
class INotifyPropertyChanged {
    <>
}
INotifyPropertyChanged <|.. QuaternaryDictionary~T1,T2~
class IReactiveSourceWithOptions {
    <>
}
IReactiveSourceWithOptions <|.. QuaternaryDictionary~T1,T2~

Implements: IQuaternaryDictionary, IDictionary (opens in a new tab), 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

Items are partitioned across four shards, each guarded by its own reader-writer lock. 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). Enumeration, ToArray, Keys and Values work on a point-in-time copy, so a consumer can call back into the dictionary while enumerating. The callbacks given to Edit run while every shard is locked and must not call back into the dictionary.

Constructors

NameSummary
.ctorInitializes a new instance of the QuaternaryDictionary class.

Properties

NameSummary
CountGets the total number of entries 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.
KeysGets a collection containing all keys from the underlying quads.
ValuesGets a collection containing all values from the underlying quads.
this[]Gets or sets the value associated with the specified key.

Methods

NameSummary
AddAdds the specified key and value to the collection.
TryAddAttempts to add the specified key and value to the cache if the key does not already exist.
AddOrUpdateAdds a new entry or updates existing value.
RemoveRemoves the value with the specified key 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.
TryGetValueAttempts to retrieve the value associated with the specified key.
AddRangeAdds a collection of key/value pairs to the cache in a single batch operation.
AddValueIndexAdds a secondary index for values using the specified key selector function.
GetValuesBySecondaryIndexRetrieves all values that match the specified key in the given secondary value index.
CreateViewBySecondaryIndexCreates a reactive view filtered by a secondary index key.
ValueMatchesSecondaryIndexDetermines whether the specified value matches the given key in the specified secondary index.
ContainsDetermines whether the dictionary contains the specified key and value pair.
LookupLooks up the value associated with the specified key.
RemoveKeysRemoves all entries with keys in the specified collection from the dictionary.
RemoveManyRemoves all entries that match the specified predicate from the dictionary.
EditPerforms a batch edit operation on the dictionary, ensuring only a single change notification is emitted.
CopyToCopies the elements of the collection to an array.
ToArrayReturns an array containing all entries in the dictionary.
CopyVersionedCopies every item and reports the version of that copy.
ContainsKeyDetermines whether the dictionary contains the specified key.
GetEnumeratorReturns an enumerator over a point-in-time copy of the dictionary.

Events

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