Interface IHeap<T>
- Namespace
- LfrlAnvil.Collections
- Assembly
- LfrlAnvil.Collections.dll
Represents a generic heap data structure.
public interface IHeap<T> : IReadOnlyHeap<T>, IReadOnlyList<T>, IReadOnlyCollection<T>, IEnumerable<T>, IEnumerable
Type Parameters
T
Value type.
- Inherited Members
- Extension Methods
Methods
Add(T)
Adds a new entry to this heap.
void Add(T item)
Parameters
item
TEntry to add.
Clear()
Removes all entries from this heap.
void Clear()
Extract()
Removes and returns an entry currently at the top of this heap.
T Extract()
Returns
- T
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.
Replace(T)
Returns and replaces an entry currently at the top of the heap with a new entry.
T Replace(T item)
Parameters
item
TReplacement entry.
Returns
- T
Removed entry.
Exceptions
- IndexOutOfRangeException
When this heap is empty.
TryExtract(out T)
Attempt to remove and return an entry currently at the top of this heap if it is not empty.
bool TryExtract(out T result)
Parameters
result
Tout 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.
TryReplace(T, out T)
Attempt to return and replace an entry currently at the top of this heap with a new entry if it is not empty.
bool TryReplace(T item, out T replaced)
Parameters
item
TReplacement entry.
replaced
Tout parameter that returns the removed entry.
Returns
- bool
true when this heap is not empty and entry has been replaced, otherwise false.