Beispiel #1
0
        public T Pop()
        {
            if (Count < 1)
            {
                throw new IndexOutOfRangeException();
            }

            return(_max.Count > _min.Count
                ? _max.Pop()
                : _min.Pop());
        }
Beispiel #2
0
        static void Main(string[] args)
        {
            var max = new MaxPQ <int>();
            var min = new MinPQ <int>();
            var mid = new MidPQ <int>();

            for (int i = 0; i < 10; i++)
            {
                max.Push(i);
                min.Push(i);
                mid.Push(i);
            }

            while (max.Count > 0 && min.Count > 0)
            {
                Console.WriteLine($"{max.Pop()} {min.Pop()} {mid.Pop()}");
            }

            Console.ReadKey();
        }