Exemplo n.º 1
0
        //Push Adds one mstack to the mstack
        public void Push(int NewStack)
        {
            //Creates new stack piece if it is empty
            if (Next == null)
            {
                Next = new mstack2();
            }

            //Assigns the data if this stack is full
            if (Data != 0)
            {
                Next.Push(Data);
            }

            Data = NewStack;
        }
Exemplo n.º 2
0
        public static void Main(string[] args)
        {
            mstack <Mstring> ms2 = new mstack <Mstring>();

            Mstring one = new Mstring("louie");
            Mstring two = new Mstring("marshy");

            ms2.Push(one);
            ms2.Push(two);



            mstack2 stack = new mstack2();

            stack.Push(10);
            stack.Push(20);
            stack.Push(30);

            Console.WriteLine(stack.Pop());
            Console.WriteLine(stack.Pop());
            Console.WriteLine(stack.Pop());


            for (int i = 0; i < 10000; i++)
            {
                stack.Push(i);
            }

            Console.WriteLine("*********************NOW POP IT*********************");
            Console.WriteLine("*********************NOW POP IT*********************");
            Console.WriteLine("*********************NOW POP IT*********************");
            Console.WriteLine("*********************NOW POP IT*********************");
            Console.WriteLine("*********************NOW POP IT*********************");
            Console.WriteLine("*********************NOW POP IT*********************");
            Console.WriteLine("*********************NOW POP IT*********************");
            Console.WriteLine("*********************NOW POP IT*********************");

            int j = 0;

            while (stack.Pop() != 0)
            {
            }

            Console.ReadKey();


            mstack <int> ms = new mstack <int>();

            for (int i = 0; i < 10000; i++)
            {
                ms.Push(i);
            }

            Console.WriteLine("*********************NOW POP IT*********************");
            Console.WriteLine("*********************NOW POP IT*********************");
            Console.WriteLine("*********************NOW POP IT*********************");
            Console.WriteLine("*********************NOW POP IT*********************");
            Console.WriteLine("*********************NOW POP IT*********************");
            Console.WriteLine("*********************NOW POP IT*********************");
            Console.WriteLine("*********************NOW POP IT*********************");
            Console.WriteLine("*********************NOW POP IT*********************");

            j = 0;
            while (ms.Pop() != 0)
            {
            }
        }