Class HashSetDictionary<TKey, TValue>
Represents a collection of keys mapped to a hash set of unique values per key.
Implements
Namespace: Singulink.Collections
Assembly: Singulink.Collections.dll
Syntax
public class HashSetDictionary<TKey, TValue> : ISetDictionary<TKey, TValue>, ICollectionDictionary<TKey, TValue, IKeyedSet<TKey, TValue>>, IReadOnlyCollectionDictionary<TKey, TValue, IKeyedSet<TKey, TValue>>, IReadOnlySetDictionary<TKey, TValue>, IReadOnlyCollectionDictionary<TKey, TValue, IReadOnlyKeyedSet<TKey, TValue>>, IReadOnlyCollectionDictionaryBase<TKey, TValue> where TKey : notnull
Type Parameters
| Name | Description |
|---|---|
| TKey | The type of the keys in the dictionary. |
| TValue | The type of the values in the dictionary. |
Constructors
| Name | Description |
|---|---|
| HashSetDictionary() | Initializes a new instance of the HashSetDictionary<TKey, TValue> class. |
| HashSetDictionary(IEqualityComparer<TKey>?, IEqualityComparer<TValue>?) | Initializes a new instance of the HashSetDictionary<TKey, TValue> class that uses the specified key and value comparers. |
| HashSetDictionary(int) | Initializes a new instance of the HashSetDictionary<TKey, TValue> class with the specified initial capacity for key/value set pairs. |
| HashSetDictionary(int, IEqualityComparer<TKey>?, IEqualityComparer<TValue>?) | Initializes a new instance of the HashSetDictionary<TKey, TValue> class with the specified initial capacity for key/value set pairs, and uses the specified key and value comparers. |
Properties
| Name | Description |
|---|---|
| Count | Gets the number of keys and associated value sets in the dictionary. |
| this[TKey] | Gets the value set associated with the specified key. If the key is not found then a new value set is returned which can be used to add values to the key or to monitor when items are added to the key. |
| KeyComparer | Gets the comparer that is used to determine equality of the keys. |
| Keys | Gets a collection containing the keys in the dictionary. |
| ValueComparer | Gets the comparer that is used to determine equality of the values. |
| ValueCount | Gets the total number of values in the dictionary across all keys. |
| ValueSets | Gets a collection containing the value sets in the dictionary. |
| Values | Gets a collection containing all the values across all the keys in the dictionary. |
Methods
| Name | Description |
|---|---|
| Clear() | Clears all keys and values from the dictionary and associated value sets. |
| Clear(TKey) | Clears the values in the set associated with the specified key and removes the key from the dictionary. |
| Contains(TKey, TValue) | Determines whether the dictionary contains the specified key associated with the specified value. |
| ContainsKey(TKey) | Determines whether the dictionary contains the specified key. |
| ContainsValue(TValue) | Returns a value indicating whether any of the value sets in the dictionary contain the specified value. |
| EnsureCapacity(int) | Ensures that the dictionary can hold up to a specified number of key/value set pairs without any further expansion of its backing storage. |
| GetAlternateLookup<TAlternateKey>() | Gets an alternate lookup that can be used to perform operations on this dictionary using |
| GetEnumerator() | Returns an enumerator that iterates through the value sets in the dictionary. |
| GetValueCount(TKey) | Gets the number of values associated with the specified key, or zero if the key is not present. |
| ToLookup() | Creates a snapshot ILookup<TKey, TElement> by copying the current contents of the dictionary using its KeyComparer. Subsequent changes to the dictionary are not reflected in the returned lookup. |
| TrimExcess(bool) | Sets the key/value set pair capacity of this dictionary to what it would be if it had been originally initialized with all its entries, and optionally trims all the value sets in the dictionary as well. |
| TrimExcess(int, bool) | Sets the key/value set pair capacity of this dictionary to hold up to a specified number of entries without any further expansion of its backing storage, and optionally trims the capacity of each value set to the actual number of values in the set. |
| TryGetAlternateLookup<TAlternateKey>(out AlternateLookup<TAlternateKey>) | Attempts to get an alternate lookup that can be used to perform operations on this dictionary using |
| TryGetValues(TKey, out ValueSet) | Gets the keyed value collection associated with the specified key. |
Explicit Interface Implementations
| Name | Description |
|---|---|
| ICollectionDictionary<TKey, TValue, IKeyedSet<TKey, TValue>>.this[TKey] | Gets the value set associated with the specified key. If the key is not found then a new value set is returned which can be used to add values to the key or to monitor when items are added to the key. |
| IReadOnlyCollectionDictionaryBase<TKey, TValue>.Keys | Gets a collection containing the keys in the dictionary. |
| IReadOnlyCollectionDictionaryBase<TKey, TValue>.Values | Gets a collection containing all the values across all the keys in the dictionary. |
| IReadOnlyCollectionDictionary<TKey, TValue, IKeyedSet<TKey, TValue>>.this[TKey] | Gets the value set associated with the specified key. If the key is not found then a new value set is returned which can be used to add values to the key or to monitor when items are added to the key. |
| IReadOnlyCollectionDictionary<TKey, TValue, IKeyedSet<TKey, TValue>>.TryGetValues(TKey, out IKeyedSet<TKey, TValue>) | Gets the keyed value collection associated with the specified key. |
| IReadOnlyCollectionDictionary<TKey, TValue, IKeyedSet<TKey, TValue>>.ValueCollections | Gets a collection containing the keyed value collections in the dictionary. |
| IReadOnlyCollectionDictionary<TKey, TValue, IReadOnlyKeyedSet<TKey, TValue>>.this[TKey] | Gets the value set associated with the specified key. If the key is not found then a new value set is returned which can be used to add values to the key or to monitor when items are added to the key. |
| IReadOnlyCollectionDictionary<TKey, TValue, IReadOnlyKeyedSet<TKey, TValue>>.TryGetValues(TKey, out IReadOnlyKeyedSet<TKey, TValue>) | Gets the keyed value collection associated with the specified key. |
| IReadOnlyCollectionDictionary<TKey, TValue, IReadOnlyKeyedSet<TKey, TValue>>.ValueCollections | Gets a collection containing the keyed value collections in the dictionary. |
| ISetDictionary<TKey, TValue>.this[TKey] | Gets the value set associated with the specified key. If the key is not found then a new value set is returned which can be used to add values to the key or to monitor when items are added to the key. |
| ISetDictionary<TKey, TValue>.TryGetValues(TKey, out IKeyedSet<TKey, TValue>) | Gets the keyed value collection associated with the specified key. |
| ISetDictionary<TKey, TValue>.ValueCollections | Gets a collection containing the value sets in the dictionary. |