コード例 #1
0
ファイル: Stack.cs プロジェクト: JamesTryand/language-ext
        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
ファイル: Stck.cs プロジェクト: JamesTryand/language-ext
 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
ファイル: Que.cs プロジェクト: pahomovda/language-ext
        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();