Class HashDictionaryInt<TKey, TValue>
A dictionary which uses hashes generated from the key to store items in a backing dictionary. We may look at generating long hashes eventually if there are many collisions detected.
Inherited Members
Namespace: Sdl.Core.Bcm.BcmModel.Collections
Assembly: Sdl.Core.Bcm.BcmModel.dll
Syntax
public class HashDictionaryInt<TKey, TValue>
Type Parameters
| Name | Description |
|---|---|
| TKey | Item from which key will be derived. At the moment, GetHashCode is called on the key to use as actual key in backing Dictionary |
| TValue | value for given key being stored in dictionary |
Constructors
HashDictionaryInt()
Initializes a new instance of the HashDictionaryInt<TKey, TValue> class.
Declaration
public HashDictionaryInt()
Fields
_backingDictionary
The backing dictionary.
Declaration
public Dictionary<int, List<KeyValuePair<TKey, TValue>>> _backingDictionary
Field Value
| Type | Description |
|---|---|
| Dictionary<int, List<KeyValuePair<TKey, TValue>>> |
Properties
this[TKey]
Gets the TKey with the specified key.
Declaration
public TValue this[TKey key] { get; }
Parameters
| Type | Name | Description |
|---|---|---|
| TKey | key | The key. |
Property Value
| Type | Description |
|---|---|
| TValue | The |
Exceptions
| Type | Condition |
|---|---|
| InvalidOperationException | Multiple matches found in collection or Key not found in collection |
Methods
Add(TKey, TValue)
Adds the specified key.
Declaration
public void Add(TKey key, TValue value)
Parameters
| Type | Name | Description |
|---|---|---|
| TKey | key | The key. |
| TValue | value | The value. |
Exceptions
| Type | Condition |
|---|---|
| InvalidOperationException | Item with same key already exists in collection |
Clear()
Removes all keys and values from this instance.
Declaration
public void Clear()
ContainsKey(TKey)
Determines whether the collection contains the specified key.
Declaration
public bool ContainsKey(TKey key)
Parameters
| Type | Name | Description |
|---|---|---|
| TKey | key | The key. |
Returns
| Type | Description |
|---|---|
| bool |
|
Exceptions
| Type | Condition |
|---|---|
| InvalidOperationException | Multiple matches found in collection |
GetHashCodeInternal(TKey)
Gets the internal hash code used in the backing dictionary.
Declaration
protected virtual int GetHashCodeInternal(TKey key)
Parameters
| Type | Name | Description |
|---|---|---|
| TKey | key | The key. |
Returns
| Type | Description |
|---|---|
| int |
Remove(TKey)
Removes the specified key.
Declaration
public bool Remove(TKey key)
Parameters
| Type | Name | Description |
|---|---|---|
| TKey | key | The key. |
Returns
| Type | Description |
|---|---|
| bool |
Exceptions
| Type | Condition |
|---|---|
| InvalidOperationException | Multiple matches found in collection |
TryGetValue(TKey, out TValue)
Tries to get a value by key.
Declaration
public bool TryGetValue(TKey key, out TValue value)
Parameters
| Type | Name | Description |
|---|---|---|
| TKey | key | The key. |
| TValue | value | The value. |
Returns
| Type | Description |
|---|---|
| bool |