Interface IDictionaryHeap<TKey, TValue>
- Namespace
- LfrlAnvil.Collections
- Assembly
- LfrlAnvil.Collections.dll
Represents a generic heap data structure with the ability to identify entries by keys.
public interface IDictionaryHeap<TKey, TValue> : IReadOnlyDictionaryHeap<TKey, TValue>, IReadOnlyHeap<TValue>, IReadOnlyList<TValue>, IReadOnlyCollection<TValue>, IEnumerable<TValue>, IEnumerable
Type Parameters
TKey
Key type.
TValue
Value type.
- Inherited Members
- Extension Methods
Methods
Add(TKey, TValue)
Adds a new entry to this heap.
void Add(TKey key, TValue value)
Parameters
key
TKeyEntry's key.
value
TValueEntry to add.
Exceptions
- ArgumentException
When
key
already exists in this heap.
AddOrReplace(TKey, TValue)
Adds or replaces an entry associated with the specified key
.
TValue AddOrReplace(TKey key, TValue value)
Parameters
key
TKeyEntry's key.
value
TValueEntry to add or replace with.
Returns
- TValue
Removed entry if
key
existed in this heap, otherwise the providedvalue
.
Clear()
Removes all entries from this heap.
void Clear()
Extract()
Removes and returns an entry currently at the top of this heap.
TValue Extract()
Returns
- TValue
Removed entry.
Exceptions
- IndexOutOfRangeException
When this heap is empty.
Pop()
Removes an entry currently at the top of this heap.
void Pop()
Exceptions
- IndexOutOfRangeException
When this heap is empty.
Remove(TKey)
Removes an entry associated with the specified key
from this heap.
TValue Remove(TKey key)
Parameters
key
TKeyEntry's key.
Returns
- TValue
Removed entry.
Exceptions
- ArgumentException
When key does not exist in this heap.
Replace(TKey, TValue)
Returns and replaces an entry currently associated with the specified key
.
TValue Replace(TKey key, TValue value)
Parameters
key
TKeyEntry's key.
value
TValueReplacement entry.
Returns
- TValue
Removed entry.
Exceptions
- KeyNotFoundException
When
key
does not exist in this heap.
TryAdd(TKey, TValue)
Attempts to add a new entry to this heap.
bool TryAdd(TKey key, TValue value)
Parameters
key
TKeyEntry's key.
value
TValueEntry to add.
Returns
- bool
true when key did not exist and entry was added, otherwise false.
TryExtract(out TValue)
Attempt to remove and return an entry currently at the top of this heap if it is not empty.
bool TryExtract(out TValue result)
Parameters
result
TValueout parameter that returns the removed entry.
Returns
- bool
true when this heap was not empty and entry has been removed, otherwise false.
TryPop()
Attempts to remove an entry currently at the top of the heap if it is not empty.
bool TryPop()
Returns
- bool
true when this heap was not empty and entry has been removed, otherwise false.
TryRemove(TKey, out TValue)
Attempts to remove an entry associated with the specified key
from this heap.
bool TryRemove(TKey key, out TValue removed)
Parameters
key
TKeyEntry's key.
removed
TValueout parameter that returns the removed entry.
Returns
- bool
true when entry was removed, otherwise false.
TryReplace(TKey, TValue, out TValue)
Attempt to return and replace an entry associated with the specified key
with a new entry if it exists.
bool TryReplace(TKey key, TValue value, out TValue replaced)
Parameters
key
TKeyEntry's key.
value
TValueReplacement entry.
replaced
TValueout parameter that returns the removed entry.
Returns
- bool
true when
key
exists in this heap, otherwise false.