mirror of
https://github.com/AlexMacocian/SystemExtensions.git
synced 2026-07-15 14:19:29 +00:00
Renamed Remove function for consistency
This commit is contained in:
@@ -101,7 +101,7 @@ namespace SystemExtensions.Collections
|
||||
/// Removes the item at the root. Throws exception if there are no items in the heap.
|
||||
/// </summary>
|
||||
/// <returns>Value removed.</returns>
|
||||
public T RemoveMinimum()
|
||||
public T Remove()
|
||||
{
|
||||
if (count == 0)
|
||||
{
|
||||
@@ -113,6 +113,19 @@ namespace SystemExtensions.Collections
|
||||
return min;
|
||||
}
|
||||
/// <summary>
|
||||
/// Peeks at the item at the root. Throws exception if there are no items in the heap.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public T Peek()
|
||||
{
|
||||
if (count == 0)
|
||||
{
|
||||
throw new IndexOutOfRangeException("Heap is empty!");
|
||||
}
|
||||
T min = items[1];
|
||||
return min;
|
||||
}
|
||||
/// <summary>
|
||||
/// Return the heap structure as an array
|
||||
/// </summary>
|
||||
/// <returns>Array with values sorted as in heap</returns>
|
||||
|
||||
@@ -56,7 +56,7 @@ namespace SystemExtensions.Collections
|
||||
{
|
||||
if (Count > 0)
|
||||
{
|
||||
return binaryHeap.RemoveMinimum();
|
||||
return binaryHeap.Remove();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -63,7 +63,7 @@ namespace SystemExtensions.Collections.Tests
|
||||
{
|
||||
Assert.Fail();
|
||||
}
|
||||
System.Diagnostics.Debug.WriteLine(binaryHeap.RemoveMinimum());
|
||||
System.Diagnostics.Debug.WriteLine(binaryHeap.Remove());
|
||||
tries--;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user