Interface IReadOnlyDictionaryHeap<TKey, TValue>
- Namespace
- LfrlAnvil.Collections
- Assembly
- LfrlAnvil.Collections.dll
Represents a generic read-only heap data structure with the ability to identify entries by keys.
public interface IReadOnlyDictionaryHeap<TKey, TValue> : IReadOnlyHeap<TValue>, IReadOnlyList<TValue>, IReadOnlyCollection<TValue>, IEnumerable<TValue>, IEnumerable
Type Parameters
TKeyKey type.
TValueValue type.
- Inherited Members
- Extension Methods
Properties
KeyComparer
Key equality comparer.
IEqualityComparer<TKey> KeyComparer { get; }
Property Value
- IEqualityComparer<TKey>
Methods
ContainsKey(TKey)
Checks whether or not an entry with the specified key exists in this heap.
[Pure]
bool ContainsKey(TKey key)
Parameters
keyTKeyKey to check.
Returns
- bool
true when entry with the specified
keyexists, otherwise false.
GetIndex(TKey)
Returns the 0-based position of an entry associated with the specified key.
[Pure]
int GetIndex(TKey key)
Parameters
keyTKeyKey to get an index for.
Returns
- int
0-based position of an entry associated with the specified
key.
Exceptions
- KeyNotFoundException
When
keydoes not exist in this heap.
GetKey(int)
Returns the key associated with an entry located at the specified index.
[Pure]
TKey GetKey(int index)
Parameters
indexint0-based position.
Returns
- TKey
Key associated with an entry located at the specified
index.
Exceptions
- IndexOutOfRangeException
When
indexis not in [0, Count) range.
GetValue(TKey)
Returns an entry associated with the specified key.
[Pure]
TValue GetValue(TKey key)
Parameters
keyTKeyKey to get an entry for.
Returns
- TValue
Entry associated with the specified
key.
Exceptions
- KeyNotFoundException
When
keydoes not exist in this heap.
TryGetValue(TKey, out TValue)
Attempts to return an entry associated with the specified key if it exists.
bool TryGetValue(TKey key, out TValue result)
Parameters
keyTKeyKey to get an entry for.
resultTValueout parameter that returns an entry associated with the specified
key.
Returns
- bool
true when key exists in this heap, otherwise false.