Ejemplo n.º 1
0
        private static void Method5()
        {
            MaxStack stack = new MaxStack();

            stack.Push(5);
            stack.Push(1);
            stack.PopMax();
            stack.PeekMax();
        }
Ejemplo n.º 2
0
        private static void Method1()
        {
            MaxStack stack = new MaxStack();

            stack.Push(5);
            stack.Push(1);
            stack.Push(5);
            stack.Top();     //-> 5
            stack.PopMax();  //-> 5
            stack.Top();     //-> 1
            stack.PeekMax(); //-> 5
            stack.Pop();     //-> 1
            stack.Top();     //-> 5
        }
Ejemplo n.º 3
0
        private static void Method3()
        {
            MaxStack stack = new MaxStack();

            stack.Push(74);
            stack.PopMax();
            stack.Push(89);
            stack.Push(67);
            stack.PopMax();
            stack.Pop();
            stack.Push(61);
            stack.Push(-77);
            stack.PeekMax();
            stack.PopMax();
        }
Ejemplo n.º 4
0
        static void Main(string[] args)
        {
            int range = 100;
            int tries = 10;
            var stack = new MaxStack();
            var rnd   = new Random();

            for (int i = 0; i < tries; i++)
            {
                int j = rnd.Next(range);
                stack.Push(j);
                Console.Write($"push: {j} max: {stack.Max()}\n");
            }
            Console.WriteLine();

            while (stack.Size() > 0)
            {
                Console.Write($"max: {stack.Max()} pop: {stack.Pop()}\n");
            }
            Console.WriteLine();
            Console.ReadKey();
        }