public void Count()
        {
            StackUsingLinkedList <int> stack = new StackUsingLinkedList <int>();

            stack.Push(10);
            stack.Push(20);
            stack.Push(30);
            stack.Push(40);

            /*
             * 40    --- Top
             * 30
             * 20
             * 10
             */

            stack.Clear();

            stack.Push(10);
            stack.Push(20);
            stack.Push(30);


            /*
             * 30   --- Top
             * 20
             * 10
             */

            Assert.AreEqual(stack.Count(), 3);
        }
예제 #2
0
            public static bool DelimiterMatching(string input)
            {
                _list.Clear();
                for (int x = 0; x < input.Length; x++)
                {
                    if (input[x] == '(' || input[x] == '[' || input[x] == '{')
                    {
                        _list.Push(input[x]);
                    }

                    else if (input[x] == ')' || input[x] == ']' || input[x] == '}')
                    {
                        if (DelimiterCheck.IsMatchingPair(_list.Pop(), input[x]) == false)
                        {
                            return(false);
                        }
                    }
                }

                return(true);
            }