public static Tuple <Stck <T>, T> popUnsafe <T>(Stck <T> stack) { T value; var newStack = stack.Pop(out value); return(Tuple(newStack, value)); }
internal Stck(Lst <T> initial) { tail = new Stck <T>(); foreach (var item in initial) { value = item; tail = tail.Push(item); Count++; } tail = tail.Pop(); }
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)); } }
/// <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);
/// <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);
/// <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();