public void PriorityQueueTest() { PriorityQueue.PriorityQueue <int> queue = new PriorityQueue.PriorityQueue <int>(); var ans = new int[] { 1, 2, 3, 4, 6, 8, 9 }; queue.Enqueue(new int[] { 1, 4, 2, 3, 9, 8, 6 }); var i = 0; while (!queue.Empty) { Assert.AreEqual(ans[i++], queue.Dequeue()); } }
private static void Main() { Stopwatch sw = new Stopwatch(); sw.Start(); List<int> inputList = new List<int>() { 1, 34, 5, 15, 250, 300, 22, 44, 52, 2, 34 }; PQ.PriorityQueue<int> queue1 = new PriorityQueue<int>(); foreach (var item in inputList) { queue1.Enqueue(item); } queue1.Enqueue(1000); while (queue1.Count > 0) { int currentRecord = queue1.Dequeue(); Console.WriteLine(currentRecord); } sw.Stop(); Console.WriteLine(sw.Elapsed); sw.Reset(); sw.Start(); PriorityQueue.PriorityQueue<int> queue = new PriorityQueue.PriorityQueue<int>(inputList); queue.Enqueue(1000); while (queue.Lenght > 0) { int currentRecord = queue.Dequeue(); Console.WriteLine(currentRecord); } sw.Stop(); Console.WriteLine(sw.Elapsed); }
public void PriorityQueueEmptyTest() { PriorityQueue.PriorityQueue <int> queue = new PriorityQueue.PriorityQueue <int>(); Assert.IsTrue(queue.Empty); }