Esempio n. 1
0
 public void EnQueue2(T data)
 {
     if (Stack1 == null)
     {
         Stack1 = new StackLinkedList <T>();
     }
     Stack1.Push(new StackNodeSingly <T>(data));
 }
Esempio n. 2
0
        public T DeQueue2()
        {
            if (Stack2 == null)
            {
                Stack2 = new StackLinkedList <T>();
            }

            while (Stack1.HeadStackNodeSingly != null)
            {
                Stack2.Push(new StackNodeSingly <T>(Stack1.Pop()));
            }

            return(Stack2.Pop());
        }
Esempio n. 3
0
        public void EnQueue1(T data)
        {
            if (Stack1 == null)
            {
                Stack1 = new StackLinkedList <T>();
            }

            if (Stack2 == null)
            {
                Stack2 = new StackLinkedList <T>();
            }
            var newData = new StackNodeSingly <T>(data);

            while (Stack1.HeadStackNodeSingly != null)
            {
                Stack2.Push(new StackNodeSingly <T>(Stack1.Pop()));
            }
            Stack1.Push(newData);
            while (Stack2.HeadStackNodeSingly != null)
            {
                Stack1.Push(new StackNodeSingly <T>(Stack2.Pop()));
            }
        }
Esempio n. 4
0
 public static void Log(StackLinkedList <int> target)
 {
     Console.WriteLine(target.toString());
 }