当前位置: 首页>>代码示例>>C#>>正文


C# Deque.PopFront方法代码示例

本文整理汇总了C#中Deque.PopFront方法的典型用法代码示例。如果您正苦于以下问题:C# Deque.PopFront方法的具体用法?C# Deque.PopFront怎么用?C# Deque.PopFront使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Deque的用法示例。


在下文中一共展示了Deque.PopFront方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Create

		private Deque<string> Create(params string[] elements)
		{
			var sut = new Deque<string>() { "_", "_", "_", "_" };

			sut.PopFront();
			sut.PopBack();
			foreach(var element in elements)
			{
				sut.PushBack(element);
			}
			sut.PopFront();
			sut.PopFront();
			return sut;
		}
开发者ID:Virtlink,项目名称:noofax,代码行数:14,代码来源:DequeTests.cs

示例2: TestRemoveAt

        public void TestRemoveAt()
        {
            Deque<int> test = new Deque<int>(6);
            test.Add(0);
            test.Add(1);
            test.Add(2);
            test.Add(3);
            test.Add(4);
            test.Add(5);

            test.PopFront();
            test.PopFront();

            test.Add(6);
            test.Add(7);

            test.RemoveAt(2);

            int[] arr = test.ToArray();

            CollectionAssert.AreEqual(arr, new int[] { 2, 3, 5, 6, 7 });
            Assert.AreEqual(test.Count, 5);
        }
开发者ID:npcook,项目名称:terminal,代码行数:23,代码来源:DequeTests.cs

示例3: TestPopFront

        private static void TestPopFront(Deque<int> deque)
        {
            deque.Clear();

            PopulateDequePushBack(deque);

            int j;

            for(int i = 0; i < ElementCount; i++)
            {
                j = (int)deque.PopFront();

                System.Diagnostics.Debug.Assert(j == i);
            }

            System.Diagnostics.Debug.Assert(deque.Count == 0);
        }
开发者ID:natural20s,项目名称:ProjectAccountingSoftware,代码行数:17,代码来源:GenericTester.cs

示例4: CreateNFA

        private void CreateNFA(string input)
        {
            Stack<char> operatorStack = new Stack<char>();
            var expandedInput = ConcatExpand(input);
            for (int i = 0; i < expandedInput.Length; i++)
            {
                char c = expandedInput[i];
                if (char.IsLetterOrDigit(c))
                    Push(c);
                else if (operatorStack.Count == 0)
                    operatorStack.Push(c);
                else if (c == '(')
                    operatorStack.Push(c);
                else if (c == ')')
                {
                    while (operatorStack.Peek() != '(')
                    {
                        var op = operatorStack.Pop();
                        if (op == (char)8)
                            Concat();
                        else if (op == '*')
                            Star();
                        else if (op == '|')
                            Union();
                        else
                            return;
                    }
                    operatorStack.Pop(); //pop up '('
                }
                else
                {
                    while (operatorStack.Count != 0 && Presedece(c, operatorStack.Peek()))
                    {
                        var op = operatorStack.Pop();
                        if (op == (char)8)
                            Concat();
                        else if (op == '*')
                            Star();
                        else if (op == '|')
                            Union();
                        else
                            return;
                    }
                    operatorStack.Push(c);
                }
            }

            while (operatorStack.Count > 0)
            {
                var op = operatorStack.Pop();
                if (op == (char)8)
                    Concat();
                else if (op == '*')
                    Star();
                else if (op == '|')
                    Union();
                else
                    return;
            }

            if (_operandStack.Count == 0)
                return;
            var A = _operandStack.Pop();
            A.GetLastState().AcceptState = true;

            #if DEBUG
            if (A.GetFirstState() != null)
            {
                using (var stream = File.OpenWrite("NFA.txt"))
                {
                    using (var sw = new StreamWriter(stream))
                    {
                        HashSet<int> processedStates = new HashSet<int>();
                        Deque<State> unprocessedStates = new Deque<State>();
                        unprocessedStates.PushBack(A.GetFirstState());

                        while(unprocessedStates.Count>0)
                        {
                            var state = unprocessedStates.PopFront();
                            var labels = state.GetLabels();
                            foreach (var label in labels)
                            {
                                var destinationStates = state.GetStates(label);
                                if (destinationStates != null)
                                {
                                    foreach (var dest in destinationStates)
                                    {
                                        sw.WriteLine("Start:" + state.ToString() + "," + "End:" + dest.ToString() + "," + "Label:" + (label!=EPSILON? label.ToString():"EPSILON"));
                                        if (!processedStates.Contains(dest.StateId))
                                        {
                                            unprocessedStates.PushBack(dest);
                                        }
                                    }
                                }
                            }
                            processedStates.Add(state.StateId);
                        }
                    }
                }
            }
//.........这里部分代码省略.........
开发者ID:hiberyan,项目名称:RegularExpressionParser,代码行数:101,代码来源:RegEx.cs


注:本文中的Deque.PopFront方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。