public T Peek() { if (IsEmpty) { throw new InvalidOperationException("Queue is empty."); } return(frontStack.Peek()); }
public T Peek() { if (this.IsEmpty) { throw new InvalidOperationException(SR.InvalidEmptyOperation); } return(_forwards.Peek()); }
/// <summary> /// Reverses the order of a stack. /// </summary> /// <returns>The reversed stack.</returns> internal ImmutableStack <T> Reverse() { var r = this.Clear(); for (ImmutableStack <T> f = this; !f.IsEmpty; f = f.Pop()) { r = r.Push(f.Peek()); } Debug.Assert(r != null); Debug.Assert(r.IsEmpty == IsEmpty); return(r); }
internal ImmutableStack <T> Reverse() { Contract.Ensures(Contract.Result <ImmutableStack <T> >() != null); Contract.Ensures(Contract.Result <ImmutableStack <T> >().IsEmpty == this.IsEmpty); var r = this.Clear(); for (ImmutableStack <T> f = this; !f.IsEmpty; f = f.Pop()) { r = r.Push(f.Peek()); } return(r); }