Beispiel #1
0
 //Pop
 public void Pop()
 {
     if (Head != null)
     {
         var newHead = Head.NextNode;
         Head = newHead;
     }
     else
     {
         Console.WriteLine("The Stack is Empty");
     }
 }
Beispiel #2
0
        //Print All

        public void PrintAll()
        {
            Console.WriteLine("Printing All Item in Linked Stack");
            StackNodes <T> CurrentNode = Head;

            while (CurrentNode != null)
            {
                Console.WriteLine(CurrentNode.Value);
                CurrentNode = CurrentNode.NextNode;
            }
            Console.WriteLine("End Printing");
        }
Beispiel #3
0
        //Push
        public void Push(T itemValue)
        {
            StackNodes <T> node = new StackNodes <T>();

            node.Value = itemValue;

            if (Head == null)
            {
                Head = node;
            }
            else
            {
                var oldHeadNode = Head;
                node.NextNode = oldHeadNode;
                Head          = node;
            }
        }