コード例 #1
0
        public int Pop()
        {
            MyStack last = GetLastStack();

            if (last == null)
            {
                throw new NullReferenceException();
            }
            int item = last.Pop();

            if (last.size == 0)
            {
                stacks.Remove(stacks[stacks.Count - 1]);
            }
            return(item);
        }
コード例 #2
0
        public int LeftShift(int index, bool removeTop)
        {
            MyStack stack = stacks[index];
            int     removed_item;

            removed_item = (removeTop) ? stack.Pop() : stack.RemoveBottom();
            if (stack.IsEmpty())
            {
                stacks.Remove(stacks[index]);
            }
            else if (stacks.Count > index + 1)
            {
                int item = LeftShift(index + 1, false);
                stack.Push(item);
            }
            return(removed_item);
        }