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


C# Queue.Clear方法代码示例

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


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

示例1: Apply

        public bool Apply(Queue<ConfigInitWizardStep> steps, Config config, string workingDirectory, IFileSystem fileSystem)
        {
            Console.WriteLine();
            Console.WriteLine(GetPrompt(config, workingDirectory, fileSystem));
            Console.WriteLine();
            Console.Write("> ");
            var input = Console.ReadLine();
            if (input == null)
            {
                Console.WriteLine("Would you like to save changes? (y/n)");
                input = Console.ReadLine();
                if (input == null || input.ToLower() == "n") return false;
                if (input.ToLower() == "y")
                {
                    steps.Clear();
                    return true;
                }

                InvalidResponse(steps);
                return true;
            }
            var resultWithDefaultApplied = string.IsNullOrEmpty(input) ? DefaultResult : input;
            var stepResult = HandleResult(resultWithDefaultApplied, steps, config, workingDirectory, fileSystem);
            if (stepResult.InvalidResponse)
            {
                InvalidResponse(steps);
            }
            else if (stepResult.Exit)
            {
                steps.Clear();
                return stepResult.Save;
            }
            return true;
        }
开发者ID:nakioman,项目名称:GitVersion,代码行数:34,代码来源:ConfigInitWizardStep.cs

示例2: ProcessQueue

        /// <summary>
        /// Process log queue.
        /// </summary>
        private void ProcessQueue()
        {
            while (true)
            {
                _waiting = true;
                HasNewItems.WaitOne(10000, true);
                _waiting = false;

                Queue<string> queueCopy;
                lock (Queue)
                {
                    queueCopy = new Queue<string>(Queue);
                    Queue.Clear();
                }

                StringBuilder sb = new StringBuilder();

                foreach (var line in queueCopy)
                {
                    sb.AppendLine(line);
                }

                WriteToLogFile(sb.ToString());
                queueCopy.Clear();
            }
        }
开发者ID:ZXeno,项目名称:IspTracker,代码行数:29,代码来源:Logger.cs

示例3: Clear_Empty

 public void Clear_Empty(int capacity)
 {
     var q = new Queue(capacity);
     Assert.Equal(0, q.Count);
     q.Clear();
     Assert.Equal(0, q.Count);
 }
开发者ID:er0dr1guez,项目名称:corefx,代码行数:7,代码来源:Queue_Clear.cs

示例4: FillGuide

		protected override async Task FillGuide(DateTime date) {
			Queue<TimeSpan> newsQueue=new Queue<TimeSpan>(5); TimeSpan previousTime=new TimeSpan(-1);
			foreach (Match match in broadcastRx.Matches(
				await client.DownloadStringTaskAsync(string.Concat("http://echo.msk.ru/schedule/", date.ToString(@"yyyy\-MM\-dd"), ".html")))) {
				GroupCollection groups=match.Groups;
				string title=htmlRx.Replace(groups["title"].Success ? groups["title"].Value:groups["notice"].Value, string.Empty);
				Match newsMatch=newsRx.Match(title);
				if (newsMatch.Success) {
					newsQueue.Clear();
					title=newsMatch.Groups["caption"].Value;
					foreach (Capture cap in newsMatch.Groups["time"].Captures)
						newsQueue.Enqueue(TimeSpan.Parse(cap.Value.Substring(0, 5))); // Substring lai atstātu tikai laiku.
				}

				var sb=new StringBuilder();
				if (groups["title"].Success && groups["notice"].Value.Length != 0) sb.Append(groups["notice"].Value);
				AddPeople("guests", "Гость ", "Гости ", sb, groups);
				AddPeople("presenters", "Ведущий ", "Ведущие ", sb, groups);

				TimeSpan time=TimeSpan.Parse(groups["time"].Value);
				while (newsQueue.Count != 0 && time >= newsQueue.Peek()) {
					TimeSpan newsTime=newsQueue.Dequeue();
					if (time != newsTime) AddBroadcast(date.Add(newsTime), "Новости", null, null);
				}
				if (time == previousTime) continue;
				AddBroadcast(date.Add(time),
					quoteRx.Replace(title.Replace("&quot;", "\""), "«$1»"),
					sb.Length != 0 ? sb.ToString():null,
					groups["url"].Success ? groups["url"].Value:null);
				previousTime=time;
			}
		}
开发者ID:drdax,项目名称:Radio,代码行数:32,代码来源:EchoGuide.cs

示例5: ClearEmptyCells

        private void ClearEmptyCells(GraphicsBalloon[,] board)
        {
            int row;
            int col;

            Queue<GraphicsBalloon> baloonsToPop = new Queue<GraphicsBalloon>();
            for (col = 7; col >= 0; col--)
            {
                for (row = 7; row >= 0; row--)
                {
                    if (!board[row, col].IsPopped)
                    {
                        baloonsToPop.Enqueue(board[row, col]);
                        board[row, col].Pop();
                    }
                }

                row = 7;
                while (baloonsToPop.Count > 0)
                {
                    board[row, col] = baloonsToPop.Dequeue();
                    board[row, col].Unpop();
                    Grid.SetRow(board[row, col], row);
                    Grid.SetColumn(board[row, col], col);
                    row--;
                }

                baloonsToPop.Clear();
            }
        }
开发者ID:Baloons-Pop-2,项目名称:Balloons-Pop-2,代码行数:30,代码来源:GraphicsTraversal.cs

示例6: GaugeShouldReturnMeasure

		public void GaugeShouldReturnMeasure ()
		{
			var queue = new Queue<int>();
			var gauge = Log.Logger.GaugeOperation("queue", "item(s)", () => queue.Count);

			gauge.Write ();
			Assert.AreEqual ("\"queue\" value = 0 item(s)", _eventSeen.RenderMessage());

			queue.Enqueue (1);
			queue.Enqueue (1);

			gauge.Write ();
			Assert.AreEqual ("\"queue\" value = 2 item(s)", _eventSeen.RenderMessage());

			queue.Dequeue ();

			gauge.Write ();
			Assert.AreEqual ("\"queue\" value = 1 item(s)", _eventSeen.RenderMessage());

			queue.Clear ();

			gauge.Write ();
			Assert.AreEqual ("\"queue\" value = 0 item(s)", _eventSeen.RenderMessage());

		}
开发者ID:pardahlman,项目名称:serilog-metrics,代码行数:25,代码来源:GaugeMeasureTests.cs

示例7: ClearEmptyCells

        /// <summary>
        /// Clears all empty cells and moves all balloons on the column to rows greater than their current one if there are vacant indexes.
        /// </summary>
        /// <param name="board">The board object of the game.</param>
        private void ClearEmptyCells(IBoard board)
        {
            int row;
            int col;

            Queue<IBalloon> baloonsToPop = new Queue<IBalloon>();
            for (col = board.Cols - 1; col >= 0; col--)
            {
                for (row = board.Rows - 1; row >= 0; row--)
                {
                    if (board[row, col] != Balloon.Default)
                    {
                        baloonsToPop.Enqueue(board[row, col]);
                        board[row, col] = Balloon.Default;
                    }
                }

                row = board.Rows - 1;
                while (baloonsToPop.Count > 0)
                {
                    board[row, col] = baloonsToPop.Dequeue();
                    row--;
                }

                baloonsToPop.Clear();
            }
        }
开发者ID:Baloons-Pop-2,项目名称:Balloons-Pop-2,代码行数:31,代码来源:TraversalEffect.cs

示例8: Request

        //Entry point.
        public static void Request(Queue<string> parameters)
        {
            #if DISABLE_CUSTOM_REQUESTS
            if (Constants.YouTubeAPIKey == Constants._DEFAULT)
            {
                App.Error("To be able to send custom requests, you need to assign your own API keys.");
                return;
            }
            #endif

            if (parameters.Count == 0)
            {
                App.Info("Uptred YouTube Request Module Interactive Mode. Type 'help' For Help, 'pop' For Exit, 'go' To Send Request.");
                while (true)
                {
                    Console.Write("Uptred\\YouTube\\Request> ");
                    string command = Console.ReadLine().Trim();
                    var p = App.Str2Args(command);

                    if (p.Count > 0 && new string[] { "pop", "exit", "quit" }.Contains(p.First().ToLower())) break;
                    RequestConfig.Interpret(p);
                }
            }
            else
            {
                RequestConfig.Interpret(parameters);
                RequestConfig.Go(parameters);
                parameters.Clear();
            }
        }
开发者ID:uptredlabs,项目名称:Shell,代码行数:31,代码来源:YouTubeHandler_Request.cs

示例9: Mine

        public void Mine()
        {
            var sequencesWithAtLeastKNodes = DataSet.SequentialData.Where(d => d.Count() > K - 1).ToList(); // all sequences of at least length k
            var distinctSequences = FilterRepeatedNavigations ? GetDistinctSequences(sequencesWithAtLeastKNodes)
                                                              : sequencesWithAtLeastKNodes;

            supportDenominator = 0;
            var tempRules = new Dictionary<string, int>();
            var navigationPattern = new Queue<char>(K);

            foreach (var nodeSequence in distinctSequences)
            {
                navigationPattern.Clear();
                foreach (var node in nodeSequence)
                {
                    navigationPattern.Enqueue(((char)(node + 64)));
                    if (navigationPattern.Count < K) continue;
                    addToDictionary(string.Join("", navigationPattern.ToArray()), tempRules, 1);
                    navigationPattern.Dequeue();
                    supportDenominator++;
                }
            }

            //remove candidate rules that do not have required support
            foreach (var supCount in tempRules.Where(supCount => supCount.Value / (double)supportDenominator >= MinimumSupport))
            {
                addToDictionary(supCount.Key, Rules, supCount.Value);
            }
            PrintRules();
        }
开发者ID:parrottsquawk,项目名称:School,代码行数:30,代码来源:KSequenceMiner.cs

示例10: PosTest1

    public bool PosTest1()
    {
        bool retVal = true;
        TestLibrary.TestFramework.BeginScenario("PosTest1: Test whether Clear() is successful when the queue is not empty.");

        try
        {
            Queue<string> TestQueue = new Queue<string>();
            TestQueue.Enqueue("one");
            TestQueue.Enqueue("two");
            TestQueue.Clear();
            if (TestQueue.Count != 0)
            {
                TestLibrary.TestFramework.LogError("P01.1", "Clear() failed when the queue is not empty!");
                retVal = false;
            }
        }
        catch (Exception e)
        {
            TestLibrary.TestFramework.LogError("P01.2", "Unexpected exception: " + e);
            TestLibrary.TestFramework.LogVerbose(e.StackTrace);
            retVal = false;
        }

        return retVal;
    }
开发者ID:CheneyWu,项目名称:coreclr,代码行数:26,代码来源:queueclear.cs

示例11: ViewQueue

        private int ENQUEUE_TIME = 30; /// Delay time between two actions

        #endif

        #region Constructors

        public ViewQueue(MapView mapView)
        {
            this.mapView = mapView;
            queue = new Queue<ItemQueue>();
            lastEnque = 0;
            queue.Clear();
        }
开发者ID:alenkacz,项目名称:Expanze,代码行数:13,代码来源:ViewQueue.cs

示例12: PutCardsBack

 public void PutCardsBack(Queue<Card> cards)
 {
     foreach (var card in cards)
     {
         _deck.CardsDeck.Enqueue(card);
     }
     cards.Clear();
 }
开发者ID:ElektroMech,项目名称:BlackJack,代码行数:8,代码来源:DeckService.cs

示例13: Floor

 public Floor(int pos)
 {
     position = pos;
     upQueue = new Queue<Person>();
     upQueue.Clear();
     downQueue = new Queue<Person>();
     downQueue.Clear();
 }
开发者ID:tatsukko,项目名称:cselevator,代码行数:8,代码来源:Floor.cs

示例14: Load

 public bool Load(Queue<Token> tokens, Type tokenizerType,TemplateGroup group)
 {
     Token curToken = tokens.Dequeue();
     Queue<Token> tmp = new Queue<Token>();
     tmp.Enqueue(new Token(regIf.Match(curToken.Content).Groups[2].Value, TokenType.COMPONENT));
     IComponent curCondition = ComponentExtractor.ExtractComponent(tmp, tokenizerType, group);
     List<IComponent> curChildren = new List<IComponent>();
     while ((tokens.Count>0)&&!regEndIf.IsMatch(tokens.Peek().Content))
     {
         if (regIf.IsMatch(tokens.Peek().Content))
         {
             IFComponent ifc = new IFComponent();
             ifc.Load(tokens, tokenizerType, group);
             curChildren.Add(ifc);
         }
         else
         {
             curToken = tokens.Peek();
             if (regElseIf.IsMatch(curToken.Content))
             {
                 _statements.Add(new IfStatement(curCondition, curChildren));
                 curChildren = new List<IComponent>();
                 curToken = tokens.Dequeue();
                 tmp.Clear();
                 tmp.Enqueue(new Token(regElseIf.Match(curToken.Content).Groups[2].Value, TokenType.COMPONENT));
                 curCondition = ComponentExtractor.ExtractComponent(tmp, tokenizerType, group);
             }
             else if (regElse.IsMatch(curToken.Content))
             {
                 _statements.Add(new IfStatement(curCondition, curChildren));
                 curChildren = new List<IComponent>();
                 curToken = tokens.Dequeue();
                 tmp.Clear();
                 tmp.Enqueue(new Token("true", TokenType.TEXT));
                 curCondition = ComponentExtractor.ExtractComponent(tmp, tokenizerType, group);
             }
             else
                 curChildren.Add(ComponentExtractor.ExtractComponent(tokens, tokenizerType, group));
         }
     }
     _statements.Add(new IfStatement(curCondition, curChildren));
     if (tokens.Count != 0)
         tokens.Dequeue();
     return true;
 }
开发者ID:marquismark,项目名称:stringtemplate,代码行数:45,代码来源:IFComponent.cs

示例15: Solve

        private void Solve(TextReader reader)
        {
            while (true) {
                var whs = reader.ReadLine().Split(' ').Select(s => int.Parse(s.Trim())).ToList();
                var width = whs[0];
                var height = whs[1];
                if (width == 0 && height == 0) {
                    return;
                }

                var map = new List<string>();
                for (int i = 0; i < height * 2 - 1; i++) {
                    var text = reader.ReadLine();
                    if (text.StartsWith(" ") && !text.EndsWith(" ")) {
                        text += " ";
                    }
                    map.Add(text);
                }

                var count = 0;
                var que = new Queue<Tuple<int, int>>();
                var newQue = new Queue<Tuple<int, int>>();
                var walked = new HashSet<Tuple<int, int>>();
                que.Enqueue(Tuple.Create(0, 0));
                while (!que.Contains(Tuple.Create(2 * width - 2, 2 * height - 2)) && que.Count > 0) {
                    newQue.Clear();

                    while (que.Count > 0) {
                        var p = que.Dequeue();
                        var x = p.Item1;
                        var y = p.Item2;

                        foreach (var dxy in dxys) {
                            if (!walked.Contains(Tuple.Create(x + dxy.Item1 * 2,
                                    y + dxy.Item2 * 2))) {
                                if (CanMove(map, x + dxy.Item1, y + dxy.Item2, x + dxy.Item1 * 2,
                                        y + dxy.Item2 * 2)) {
                                    newQue.Enqueue(Tuple.Create(x + dxy.Item1 * 2, y + dxy.Item2 * 2));
                                    walked.Add(Tuple.Create(x + dxy.Item1 * 2, y + dxy.Item2 * 2));
                                }
                            }
                        }
                    }

                    var tmpQue = que;
                    que = newQue;
                    newQue = tmpQue;
                    count++;
                }

                if (que.Count == 0) {
                    Console.WriteLine(0);
                } else {
                    Console.WriteLine(count + 1);
                }
            }
        }
开发者ID:exKAZUu,项目名称:ProgrammingContests,代码行数:57,代码来源:ProblemC.cs


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