Renamed Remove function for consistency

This commit is contained in:
2019-06-20 03:51:49 +02:00
parent e374d38d4e
commit 72267a5bf4
3 changed files with 16 additions and 3 deletions
+14 -1
View File
@@ -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--;
}
}