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


C# Queue.Concat方法代码示例

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


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

示例1: GetReplaysInFolder

        public static HashSet<String> GetReplaysInFolder(String folderPath, ReplayType type, bool recursive = true)
        {
            HashSet<String> replaysInFolder;

            if (type == ReplayType.Warcraft3)
            {
                //make a set of replays in the folder, and replays that exist
                replaysInFolder = new HashSet<String>(Directory.GetFiles(folderPath, "*.w3g"));

                if (recursive)
                {
                    Queue<String> directories = new Queue<String>(Directory.GetDirectories(folderPath));
                    while (directories.Count > 0)
                    {
                        String dir = directories.Dequeue();
                        replaysInFolder = new HashSet<String>(replaysInFolder.Concat(Directory.GetFiles(dir, "*.w3g")));
                        directories = new Queue<String>(directories.Concat(Directory.GetDirectories(dir)));
                    }

                    HashSet<String> existingReplays = DatabaseHandler.GetWarcraft3ReplayPaths();
                    replaysInFolder.ExceptWith(existingReplays);
                }
            }

            //add new replay types here, otherwise an exception is thrown
            else
            {
                throw new ArgumentException();
            }

            return replaysInFolder;
        }
开发者ID:johnhforrest,项目名称:war3-dotnet-parser,代码行数:32,代码来源:FileHandler.cs

示例2: waitForMsg

        private byte[] waitForMsg(byte[] leadingBytes, int wait_ms)
        {
            Queue<ANT_Response> msgSave = new Queue<ANT_Response>();
            int i = 0;
            ANT_Response curResponse;

            System.Diagnostics.Stopwatch waitTimer = new System.Diagnostics.Stopwatch();
            waitTimer.Start();
            do
            {
                while (responseBuf.Count > 0)
                {
                    curResponse = responseBuf.Dequeue();
                    msgSave.Enqueue(curResponse);
                    //If the leading bytes match our expected response
                    if (curResponse.responseID.Equals(leadingBytes[0]))
                    {
                        //Check message id matches
                        for (i = 1; i < leadingBytes.Length; ++i)
                        {
                            //Check remaining bytes to check
                            if (!curResponse.messageContents[i - 1].Equals(leadingBytes[i]))
                                break;
                        }
                        //If all bytes matched return the remaining bytes of the message
                        if (i == leadingBytes.Length)
                        {
                            //Save the seen messages back to the response buffer
                            responseBuf = new Queue<ANT_Response>(msgSave.Concat(responseBuf));

                            //Send out the information
                            lastAcceptedResponse = curResponse;
                            i -= 1; //Start at the byte we were at
                            return curResponse.messageContents.Skip(i).ToArray();
                        }
                    }

                }
            } while (waitTimer.ElapsedMilliseconds < wait_ms);

            //If we didn't find a matching response
            responseBuf = new Queue<ANT_Response>(msgSave.Concat(responseBuf));
            lastAcceptedResponse = null;
            throw new Exception("Expected Message Timeout");
        }
开发者ID:Cycli,项目名称:Cycli,代码行数:45,代码来源:ANT_IntegratedANTFSClient.cs

示例3: WaitForNextMatchMsg

        /// <summary>
        /// Wait for a message matching the desired pattern
        /// </summary>
        /// <param name="matchPattern">Pattern to match</param>
        /// <param name="wait_ms">time to wait, in ms</param>
        /// <returns>True if the matching message is seen in the configured timeout</returns>
        public bool WaitForNextMatchMsg(int[] matchPattern, int wait_ms)
        {
            Queue<ANT_Response> msgSave = new Queue<ANT_Response>();
            ANT_Response curResponse;
            int i;

            responseBuf.Clear();
            System.Diagnostics.Stopwatch waitTimer = new System.Diagnostics.Stopwatch();
            waitTimer.Start();
            do
            {
                while (responseBuf.Count > 0)
                {
                    System.Threading.Thread.Sleep(10); //Allow time for a new message to arrive
                    curResponse = responseBuf.Dequeue();
                    msgSave.Enqueue(curResponse);
                    //Check each byte with the conditional match function against the given conditional byte match array
                    if (compareConditionalByte(curResponse.responseID, matchPattern[0]) && curResponse.messageContents.Length == (matchPattern.Length - 1))
                    {
                        //Check message id matches
                        for (i = 1; i < matchPattern.Length; ++i)
                        {
                            //Check remaining bytes to check
                            if (!compareConditionalByte(curResponse.messageContents[i - 1], matchPattern[i]))
                                break;
                        }
                        //If all bytes matched then we succeeded
                        if (i == matchPattern.Length)
                        {
                            //Save all the seen messages back to the buffer
                            responseBuf = new Queue<ANT_Response>(msgSave.Concat(responseBuf));
                            lastAcceptedResponse = curResponse;
                            return true;
                        }
                    }
                }
            } while (waitTimer.ElapsedMilliseconds < wait_ms);

            //If we didn't find a match
            responseBuf = new Queue<ANT_Response>(msgSave.Concat(responseBuf));
            lastAcceptedResponse = null;
            return false;
        }
开发者ID:Cycli,项目名称:Cycli,代码行数:49,代码来源:ANT_IntegratedANTFSClient.cs

示例4: scaning

        //-----------------------------------------------
        /// <summary>	/// сканирование карты с просчетом минимального пути до каждой вершины из расположения бота
        /// </summary>
        internal void scaning( )
        {
            int distance = 1;
            Queue<MapSector> queue = new Queue<MapSector> ();
            MapSector temp = new MapSector ( api.getCoordOfMe (),api.getCoordOfMe (),distance );
            queue.Enqueue (temp);

            int levelCount = 1;			 // кол-во вершин на данной волне
            int nextLevelCount = 0;	 // на след волне

            while ( queue.Count>0 ) {
                while ( levelCount>0 ) {
                    temp = queue.Dequeue ();											// достали вершину из очереди, пора узнать что в ней изменилось
                    if (api.isNorm(temp.xy))
                    {
                        this.mapSectorReLoad(temp);									// анализ изменений в ячейке
                        queue.Concat ( temp.getAllUsableSectors ( distance,ref nextLevelCount ) );  	//всех соседей данной вершины графа
                        levelCount--;																																	// добавили в имеющуюся очередь
                        // обновили информацию о вершине
                        recycleSectors.Enqueue(temp);
                    }
                }
                levelCount = nextLevelCount;
                nextLevelCount = 0;
                distance++;				 // удаленность волны
            }
        }
开发者ID:Pycz,项目名称:FightWithShadow,代码行数:30,代码来源:Radar.cs


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