Пример #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();
            }
        }
Пример #2
0
        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());
            }
        }
Пример #3
0
 public PriorityQueue(int length, AdvancedHeap <T> .PriorityComparison comparison)
 {
     _heap = new AdvancedHeap <T>(length, comparison);
 }