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> ); }
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)); }
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())); }
public T PeekLeft() { return(myLeft.PeekLeft()); }