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
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¶
| Name | Summary |
|---|---|
| .ctor | Initializes a new instance of the QuaternaryDictionary class. |
Properties¶
| Name | Summary |
|---|---|
| Count | Gets the total number of entries contained in all shards. |
| IsReadOnly | Gets a value indicating whether the collection is read-only. |
| Stream | Gets an observable sequence that emits cache change notifications as they occur. |
| VersionedStream | Gets an observable of change notifications, each paired with the version the change produced. |
| Options | Gets the options that apply for the lifetime of the source. |
| IsDisposed | Gets a value indicating whether the object has been disposed. |
| Version | Gets the current version number of the collection, which is incremented on each modification. |
| Keys | Gets a collection containing all keys from the underlying quads. |
| Values | Gets a collection containing all values from the underlying quads. |
| this[] | Gets or sets the value associated with the specified key. |
Methods¶
| Name | Summary |
|---|---|
| Add | Adds the specified key and value to the collection. |
| TryAdd | Attempts to add the specified key and value to the cache if the key does not already exist. |
| AddOrUpdate | Adds a new entry or updates existing value. |
| Remove | Removes the value with the specified key from the collection. |
| Clear | Removes all items from the cache. |
| DeferNotifications | Defers change notifications until the last active deferral is disposed. |
| Dispose | Releases all resources used by the current instance. |
| TryGetValue | Attempts to retrieve the value associated with the specified key. |
| AddRange | Adds a collection of key/value pairs to the cache in a single batch operation. |
| AddValueIndex | Adds a secondary index for values using the specified key selector function. |
| GetValuesBySecondaryIndex | Retrieves all values that match the specified key in the given secondary value index. |
| CreateViewBySecondaryIndex | Creates a reactive view filtered by a secondary index key. |
| ValueMatchesSecondaryIndex | Determines whether the specified value matches the given key in the specified secondary index. |
| Contains | Determines whether the dictionary contains the specified key and value pair. |
| Lookup | Looks up the value associated with the specified key. |
| RemoveKeys | Removes all entries with keys in the specified collection from the dictionary. |
| RemoveMany | Removes all entries that match the specified predicate from the dictionary. |
| Edit | Performs a batch edit operation on the dictionary, ensuring only a single change notification is emitted. |
| CopyTo | Copies the elements of the collection to an array. |
| ToArray | Returns an array containing all entries in the dictionary. |
| CopyVersioned | Copies every item and reports the version of that copy. |
| ContainsKey | Determines whether the dictionary contains the specified key. |
| GetEnumerator | Returns an enumerator over a point-in-time copy of the dictionary. |
Events¶
| Name | Summary |
|---|---|
| CollectionChanged | Occurs when the collection changes. |
| PropertyChanged | Occurs when a property value changes. |
Inherited members
System.Object.Equals(System.Object)(opens in a new tab)System.Object.Equals(System.Object,System.Object)(opens in a new tab)System.Object.GetHashCode(opens in a new tab)System.Object.GetType(opens in a new tab)System.Object.MemberwiseClone(opens in a new tab)System.Object.ReferenceEquals(System.Object,System.Object)(opens in a new tab)System.Object.ToString(opens in a new tab)