Ejemplo n.º 1
0
        public T Dequeue()
        {
            //if (IsEmpty())
            //    return default;

            if (oldestFirst.IsEmpty())
            {
                SwapStacks();
            }

            return(oldestFirst.Pop());
        }
Ejemplo n.º 2
0
 private void SwapStacks(MyStack <T> sending, MyStack <T> receiving)
 {
     while (!sending.IsEmpty())
     {
         var nodeToSwap = sending.Pop();
         receiving.Push(nodeToSwap);
     }
 }
Ejemplo n.º 3
0
 public bool IsEmpty()
 {
     return(newestFirst.IsEmpty() && oldestFirst.IsEmpty());
 }