Exemplo n.º 1
0
 public IDeque <T> EnqueueLeft(T value)
 {
     if (!Left.Full)
     {
         return(new Deque <T>(Left.EnqueueLeft(value), Middle, Right));
     }
     return(new Deque <T>(
                new Two(value, Left.PeekLeft()),
                Middle.EnqueueLeft(Left.DequeueLeft()),
                Right));
 }
Exemplo n.º 2
0
 public IDeque <T> DequeueLeft()
 {
     return((1 < myLeft.Capacity)
                         ? new Deque <T>(myLeft.DequeueLeft(), myMiddle, myRight, myLongCount - 1)
                         : (!myMiddle.IsEmpty)
                                 ? new Deque <T>(myMiddle.PeekLeft(), myMiddle.DequeueLeft(), myRight, myLongCount - 1)
                                 : (1 < myRight.Capacity)
                                         ? new Deque <T>(new One(myRight.PeekLeft()), myMiddle, myRight.DequeueLeft(), myLongCount - 1)
                                         : new SingleDequeue(myRight.PeekLeft()) as IDeque <T>
            );
 }
Exemplo n.º 3
0
 public IDeque <T> DequeueLeft()
 {
     if (Left.Size > 1)
     {
         return(new Deque <T>(Left.DequeueLeft(), Middle, Right));
     }
     if (!Middle.IsEmpty)
     {
         return(new Deque <T>(Middle.PeekLeft(), Middle.DequeueLeft(), Right));
     }
     if (Right.Size > 1)
     {
         return(new Deque <T>(new One(Right.PeekLeft()), Middle, Right.DequeueLeft()));
     }
     return(new SingleDeque(Right.PeekLeft()));
 }