Ejemplo n.º 1
0
        private void AddFirst(T Data)
        {
            var myStackNodeList = new StackNodeList <T>();

            myStackNodeList.StackNode = new StackNode <T>(Data);
            myStackNodeList.Top       = this.Top;
            this.Top = myStackNodeList;
        }
Ejemplo n.º 2
0
        private void AddLast(T Data)
        {
            var myStackNodeList = new StackNodeList <T>();

            myStackNodeList.StackNode = new StackNode <T>(Data);
            myStackNodeList.Top       = this.Top;
            mincount = 1;
            this.Top = myStackNodeList;
        }
Ejemplo n.º 3
0
 public void Pop()
 {
     if (Top == null)
     {
         throw new Exception("Empty Stack Exception");
     }
     if (this.Top.StackNode == null)
     {
         this.Top = this.Top.Top;
     }
     this.Top.StackNode = this.Top.StackNode.Top;
 }
Ejemplo n.º 4
0
        static void Main(string[] args)
        {
            StackNodeList <int> myStackNodeList = new StackNodeList <int>();

            myStackNodeList.Push(1);
            myStackNodeList.Push(2);
            myStackNodeList.Push(3);
            myStackNodeList.Push(4);
            myStackNodeList.Push(5);
            myStackNodeList.Push(6);
            myStackNodeList.Push(7);
            myStackNodeList.Push(8);
            myStackNodeList.Push(9);
            myStackNodeList.Push(10);
            myStackNodeList.Push(11);
            myStackNodeList.Push(12);
            myStackNodeList.Push(13);
            myStackNodeList.Push(14);
            myStackNodeList.Push(15);
            myStackNodeList.Push(16);
            myStackNodeList.Push(17);
            myStackNodeList.Push(18);
            myStackNodeList.Push(19);
            myStackNodeList.Push(20);
            myStackNodeList.Push(21);
            myStackNodeList.Push(22);
            myStackNodeList.Push(23);
            myStackNodeList.Push(24);
            myStackNodeList.Push(25);
            myStackNodeList.Pop();
            myStackNodeList.Pop();
            myStackNodeList.Pop();
            myStackNodeList.Pop();
            myStackNodeList.Pop();
            myStackNodeList.Pop();
            myStackNodeList.Pop();
            myStackNodeList.Pop();
            myStackNodeList.Pop();
            myStackNodeList.Pop();
            myStackNodeList.Pop();
            myStackNodeList.Pop();
            myStackNodeList.Pop();
            myStackNodeList.Pop();
            myStackNodeList.Pop();

            myStackNodeList.PrintAll();
        }
Ejemplo n.º 5
0
        public void PrintAll()
        {
            if (this.Top.StackNode == null)
            {
                this.Top = this.Top.Top;
            }
            StackNodeList <T> nextNodeList = this.Top;
            int count = 1;

            while (nextNodeList != null)
            {
                Console.WriteLine("-------Stack " + count.ToString() + " ------- Started");
                StackNode <T> nextStackNode = nextNodeList.StackNode;
                nextStackNode.PrintAll();
                nextNodeList = nextNodeList.Top;
                Console.WriteLine("-------Stack " + count.ToString() + " ------- Ended");
                count++;
            }
        }