/// <summary> /// extracts value using first-in first out approach /// </summary> /// <returns> value removed</returns> public Node Dequeue1() { if (Primary.Top == null) /// check to see if stack is empty { return(null); } else if (Primary.Top.Next == null) /// check to see if single stack { Node newNode = Primary.Pop(); return(newNode); } else { while (Primary.Top.Next != null) ///pop from primary stack into secondary stack { Node newNode = Primary.Pop(); Secondary.Push(newNode.Value); } Node temp = Secondary.Top; while (Secondary.Top != null) ///pop from secondary stack onto primary stack { Primary.Top = temp.Next; temp.Next = null; Node newNode = Secondary.Pop(); Primary.Push(newNode.Value); } } return(Secondary.Pop()); }