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
TKeyKey type.
TValueValue type.
- Inherited Members
- Extension Methods
Methods
Add(TKey, TValue)
Adds a new entry to this heap.
void Add(TKey key, TValue value)
Parameters
keyTKeyEntry's key.
valueTValueEntry to add.
Exceptions
- ArgumentException
When
keyalready exists in this heap.
AddOrReplace(TKey, TValue)
Adds or replaces an entry associated with the specified key.
TValue AddOrReplace(TKey key, TValue value)
Parameters
keyTKeyEntry's key.
valueTValueEntry to add or replace with.
Returns
- TValue
Removed entry if
keyexisted 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
keyTKeyEntry'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
keyTKeyEntry's key.
valueTValueReplacement entry.
Returns
- TValue
Removed entry.
Exceptions
- KeyNotFoundException
When
keydoes not exist in this heap.
TryAdd(TKey, TValue)
Attempts to add a new entry to this heap.
bool TryAdd(TKey key, TValue value)
Parameters
keyTKeyEntry's key.
valueTValueEntry 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
resultTValueout 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
keyTKeyEntry's key.
removedTValueout 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
keyTKeyEntry's key.
valueTValueReplacement entry.
replacedTValueout parameter that returns the removed entry.
Returns
- bool
true when
keyexists in this heap, otherwise false.