mirror of
https://github.com/AlexMacocian/SystemExtensions.git
synced 2026-07-24 03:56:27 +00:00
Uniformization
This commit is contained in:
@@ -7,10 +7,10 @@ using System.Threading.Tasks;
|
||||
namespace SystemExtensions.Collections
|
||||
{
|
||||
/// <summary>
|
||||
/// Fibonacci Heap implementation. Implements IDisposable to clear the sub structure of the heap.
|
||||
/// Fibonacci Heap implementation.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">Provided type</typeparam>
|
||||
public class FibonacciHeap<T> : IDisposable
|
||||
public class FibonacciHeap<T>
|
||||
{
|
||||
#region Fields
|
||||
private FibonacciNode<T> root;
|
||||
@@ -75,7 +75,6 @@ namespace SystemExtensions.Collections
|
||||
root = Merge(root, otherHeap.root);
|
||||
otherHeap.root = null;
|
||||
count += otherHeap.count;
|
||||
otherHeap.Dispose();
|
||||
}
|
||||
/// <summary>
|
||||
/// Remove the minimum value from the heap.
|
||||
@@ -424,40 +423,6 @@ namespace SystemExtensions.Collections
|
||||
return null;
|
||||
}
|
||||
#endregion
|
||||
#region IDisposable Support
|
||||
private bool disposedValue = false;
|
||||
/// <summary>
|
||||
/// Disposes of the contents of the heap. Called by the public Dispose().
|
||||
/// </summary>
|
||||
/// <param name="disposing"></param>
|
||||
protected virtual void Dispose(bool disposing)
|
||||
{
|
||||
if (!disposedValue)
|
||||
{
|
||||
if (root != null)
|
||||
{
|
||||
if (disposing)
|
||||
{
|
||||
Remove(root);
|
||||
}
|
||||
root.Previous = root.Next = root.Parent = root.Child = null;
|
||||
root = null;
|
||||
}
|
||||
|
||||
disposedValue = true;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Disposes of the contents of the heap.
|
||||
/// </summary>
|
||||
public void Dispose()
|
||||
{
|
||||
// Do not change this code. Put cleanup code in Dispose(bool disposing) above.
|
||||
Dispose(true);
|
||||
// TODO: uncomment the following line if the finalizer is overridden above.
|
||||
// GC.SuppressFinalize(this);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
||||
internal class FibonacciNode<T>
|
||||
|
||||
@@ -40,7 +40,6 @@ namespace SystemExtensions.Collections.Tests
|
||||
[TestMethod()]
|
||||
public void FibonacciHeapTest()
|
||||
{
|
||||
fibonacciHeap.Dispose();
|
||||
fibonacciHeap = new FibonacciHeap<int>(new Comparison<int>(IntegerComparison));
|
||||
if(fibonacciHeap.Count != 0)
|
||||
{
|
||||
@@ -51,7 +50,6 @@ namespace SystemExtensions.Collections.Tests
|
||||
[TestMethod()]
|
||||
public void MergeTest()
|
||||
{
|
||||
fibonacciHeap.Dispose();
|
||||
FibonacciHeap<int> fibonacciHeap1 = new FibonacciHeap<int>(new Comparison<int>(IntegerComparison));
|
||||
FibonacciHeap<int> fibonacciHeap2 = new FibonacciHeap<int>(new Comparison<int>(IntegerComparison));
|
||||
|
||||
@@ -150,26 +148,6 @@ namespace SystemExtensions.Collections.Tests
|
||||
}
|
||||
}
|
||||
|
||||
[TestMethod()]
|
||||
public void DisposeTest()
|
||||
{
|
||||
List<FibonacciHeap<int>> heaps = new List<Collections.FibonacciHeap<int>>();
|
||||
for(int i = 0; i < 10; i++)
|
||||
{
|
||||
heaps.Add(new Collections.FibonacciHeap<int>(new Comparison<int>(IntegerComparison)));
|
||||
for(int j = 0; j < 10000; j++)
|
||||
{
|
||||
heaps[heaps.Count - 1].Insert(j);
|
||||
}
|
||||
}
|
||||
for(int i = 0; i < 10; i++)
|
||||
{
|
||||
heaps[i].Dispose();
|
||||
}
|
||||
GC.Collect();
|
||||
heaps.Clear();
|
||||
}
|
||||
|
||||
[TestMethod()]
|
||||
public void ToArrayTest()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user