public void Enqueue(T value, int priority = 0) { lock (_mutex) { _heap.Add(new QueueEntry <T>(value, priority)); } }
//Demo: add and remove public static void Demo() { var heap = new BinaryHeap(50); int[] a = { 83, 25, 4, 92, 80, 70, 35, 29, 16, 35 }; foreach (var i in a) { heap.Add(i); } heap.Show(); Console.WriteLine(heap.isVerified()); for (int i = 0; i != 5; ++i) { heap.RemoveLargest(); heap.Show(); Console.WriteLine(heap.isVerified()); } }