Example #1
0
        public static void Test()
        {
            const int size = 5;
            var       pq   = new PriorityQueueMax(size);

            int[] a = new int[] { 3, 2, 5, 1, 9, 4, 8, 6, 7 };

            for (int i = 0; i < a.Length; i++)
            {
                if (pq.Count() < size)
                {
                    pq.Add(a[i]);
                }
                else if (a[i] < pq.GetMax())
                {
                    pq.RemoveMax();
                    pq.Add(a[i]);
                }
            }

            pq.GetAll().PrintToConsole();
            pq.GetAll().PrintToConsole();
        }
Example #2
0
        public static void Test()
        {
            const int size = 5;
            var pq = new PriorityQueueMax(size);
            int[] a = new int[] { 3, 2, 5, 1, 9, 4, 8, 6, 7 };

            for (int i = 0; i < a.Length; i++)
            {
                if (pq.Count() < size)
                {
                    pq.Add(a[i]);
                }
                else if (a[i] < pq.GetMax())
                {
                    pq.RemoveMax();
                    pq.Add(a[i]);
                }
            }

            pq.GetAll().PrintToConsole();
            pq.GetAll().PrintToConsole();
        }