public void FibonacciHeapJPerformance() { var fib = new FibonacciHeapJ <string>(); Assert.IsTrue(fib.Count == 0); var rnd = new Random(0); var ent = new FibonacciHeapJ <string> .Entry[runs]; for (int i = 0; i < runs; i++) { ent[i] = fib.Enqueue(rnd.NextDouble(), "x"); } for (int i = 0; i < runs / 2; i++) { var nd = rnd.NextDouble(); fib.ChangeKey(ent[i], nd); } for (int i = 0; i < runs / 2; i++) { ent[i] = fib.Enqueue(rnd.NextDouble(), "x"); fib.Dequeue(); } Assert.IsTrue(fib.Count == runs); for (int i = 0; i < runs; i++) { Assert.IsTrue(fib.Dequeue().Value == "x"); } Assert.IsTrue(fib.Count == 0); }
public void FibbonaciJCorrectness() { var fib = new FibonacciHeapJ <string>(); Assert.IsTrue(fib.Count == 0); fib.Enqueue(2, "find"); fib.Enqueue(3, "das"); fib.Enqueue(1, "ich"); fib.Enqueue(4, "sehr"); fib.Enqueue(6, "gut"); Assert.IsTrue(fib.Count == 5); Assert.IsTrue(fib.Dequeue().Value == "ich"); Assert.IsTrue(fib.Dequeue().Value == "find"); Assert.IsTrue(fib.Dequeue().Value == "das"); Assert.IsTrue(fib.Dequeue().Value == "sehr"); Assert.IsTrue(fib.Dequeue().Value == "gut"); Assert.IsTrue(fib.Count == 0); }