public T Peek()
 {
     if (IsEmpty)
     {
         throw new InvalidOperationException("Queue is empty.");
     }
     return(frontStack.Peek());
 }
Пример #2
0
        public T Peek()
        {
            if (this.IsEmpty)
            {
                throw new InvalidOperationException(SR.InvalidEmptyOperation);
            }

            return(_forwards.Peek());
        }
Пример #3
0
        /// <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);
        }
Пример #4
0
        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);
        }