Beispiel #1
0
        public static void HeapSort(int[] array)
        {
            AdvancedHeap <int> heap = new AdvancedHeap <int>(100, (value1, value2) => value2 - value1 >= 0);

            foreach (int value in array)
            {
                heap.Insert(value);
            }

            for (int i = 0; i < array.Length; i++)
            {
                array[i] = heap.Delete();
            }
        }
        public static void DisplayAdvancedHeap()
        {
            AdvancedHeap <char> heap = new AdvancedHeap <char>(
                100,
                (value1, value2) => value2 - value1 < 0
                );

            heap.Insert('A');
            heap.Insert('B');
            heap.Insert('C');

            Console.WriteLine(heap.Delete());

            heap.Insert('A');
            heap.Insert('B');
            heap.Insert('C');

            Console.WriteLine(heap.Delete());

            while (!heap.IsEmpty())
            {
                Console.WriteLine(heap.Delete());
            }
        }
 public void Enqueue(T value)
 {
     _heap.Insert(value);
 }