示例#1
0
        public static Tuple <Stck <T>, T> popUnsafe <T>(Stck <T> stack)
        {
            T   value;
            var newStack = stack.Pop(out value);

            return(Tuple(newStack, value));
        }
示例#2
0
 internal Stck(Lst <T> initial)
 {
     tail = new Stck <T>();
     foreach (var item in initial)
     {
         value = item;
         tail  = tail.Push(item);
         Count++;
     }
     tail = tail.Pop();
 }
示例#3
0
        public Que <T> Dequeue()
        {
            var f = forward.Pop();

            if (!f.IsEmpty)
            {
                return(new Que <T>(f, backward));
            }
            else if (backward.IsEmpty)
            {
                return(Empty);
            }
            else
            {
                return(new Que <T>(BackwardRev, Stck <T> .Empty));
            }
        }
示例#4
0
 /// <summary>
 /// Pop and match
 /// </summary>
 /// <typeparam name="R">Return type</typeparam>
 /// <param name="Some">Handler if there is a value on the top of the stack</param>
 /// <param name="None">Handler if the stack is empty</param>
 /// <returns>Return value from Some or None</returns>
 public static R pop <T, R>(Stck <T> stack, Func <Stck <T>, T, R> Some, Func <R> None) =>
 stack.Pop(Some, None);
示例#5
0
 /// <summary>
 /// Pop and match
 /// </summary>
 /// <param name="Some">Handler if there is a value on the top of the stack</param>
 /// <param name="None">Handler if the stack is empty</param>
 /// <returns>Popped stack</returns>
 public static Stck <T> pop <T>(Stck <T> stack, Action <T> Some, Action None) =>
 stack.Pop(Some, None);
示例#6
0
 /// <summary>
 /// Pop an item off the top of the stack
 /// NOTE: Will throw an InvalidOperationException if the stack is empty
 /// </summary>
 /// <exception cref="InvalidOperationException">Stack is empty</exception>
 /// <returns>Stack with the top item popped</returns>
 public static Stck <T> pop <T>(Stck <T> stack) =>
 stack.Pop();