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


C# Queue.Reverse方法代码示例

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


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

示例1: GetShortestSequence

        private static IEnumerable<int> GetShortestSequence(int start, int end)
        {
            var sequence = new Queue<int>();

            while (start <= end)
            {
                sequence.Enqueue(end);

                if (end / 2 > start)
                {
                    if (end % 2 == 0)
                    {
                        end /= 2;
                    }
                    else
                    {
                        end--;
                    }
                }
                else
                {
                    if (end - 2 >= start)
                    {
                        end -= 2;
                    }
                    else
                    {
                        end--;
                    }
                }
            }

            return sequence.Reverse();
        }
开发者ID:SimoPrG,项目名称:Data-Structures-and-Algorithms-Homework,代码行数:34,代码来源:Program.cs

示例2: DisplayShortestSequence

        private static void DisplayShortestSequence(int start, int target)
        {
            var sequence = new Queue<int>();

            while (start <= target)
            {
                sequence.Enqueue(target);

                if (target / 2 >= start)
                {
                    if (target % 2 == 0)
                    {
                        target /= 2;
                    }
                    else
                    {
                        target--;
                    }
                }
                else
                {
                    if (target - 2 >= start)
                    {
                        target -= 2;
                    }
                    else
                    {
                        target--;
                    }
                }
            }

            Console.WriteLine(string.Join(" -> ", sequence.Reverse()));
        }
开发者ID:InKolev,项目名称:TelerikAcademy,代码行数:34,代码来源:Program.cs

示例3: Main

        public static void Main()
        {
            int start = 5;
            int end = 16;
            Queue<int> quene = new Queue<int>();

            while (end >= start)
            {
                quene.Enqueue(end);
                if (end / 2 >= start)
                {
                    if (end % 2 == 0)
                    {
                        end /= 2;
                    }
                    else
                    {
                        end--;
                    }
                }
                else if (end - 2 >= start)
                {
                    end -= 2;
                }
                else
                {
                    end--;
                }
            }

            Console.WriteLine(string.Join(", ", quene.Reverse()));
        }
开发者ID:dchakov,项目名称:Data-Structures-and-Algorithms_HW,代码行数:32,代码来源:StartUp.cs

示例4: FindShortestSequenceOfOperations

        public static void FindShortestSequenceOfOperations(int start, int end)
        {
            Queue<int> steps = new Queue<int>();
            int current = end;

            while (current >= start)
            {
                steps.Enqueue(current);

                if (current / 2 >= start)
                {
                    if (current % 2 == 0)
                    {
                        current /= 2;
                    }
                    else
                    {
                        current -= 1;
                    }
                }
                else if (current - 2 >= start)
                {
                    current -= 2;
                }
                else
                {
                    current -= 1;
                }
            }
            Console.WriteLine(string.Join(" -> ", steps.Reverse()));
        }
开发者ID:zvet80,项目名称:TelerikAcademyHomework,代码行数:31,代码来源:SequenceOfOperations.cs

示例5: reconstruct_path

 private Queue<Vector2> reconstruct_path(Dictionary<Node, Node> came_from, Node current)
 {
     Queue<Vector2> path = new Queue<Vector2>();
     path.Enqueue(current.place);
     while(came_from.ContainsKey(current))
     {
         current = came_from[current];
         path.Enqueue(current.place);
     }
     return new Queue<Vector2>( path.Reverse());
 }
开发者ID:kosstbarz,项目名称:Scripts,代码行数:11,代码来源:AStar.cs

示例6: Main

        public static void Main()
        {
            Console.Write("Enter sequence start: ");
            int startNumber = int.Parse(Console.ReadLine());

            Console.Write("Enter sequence end: ");
            int endNumber = int.Parse(Console.ReadLine());

            Queue<int> operations = new Queue<int>();

            while (startNumber <= endNumber)
            {
                operations.Enqueue(endNumber);

                if (endNumber / 2 >= startNumber)
                {
                    if (endNumber % 2 == 0)
                    {
                        endNumber /= 2;
                    }
                    else
                    {
                        endNumber--;
                    }
                }
                else
                {
                    if (endNumber - 2 >= startNumber)
                    {
                        endNumber -= 2;
                    }
                    else
                    {
                        endNumber--;
                    }
                }
            }

            Console.WriteLine(string.Join(" -> ", operations.Reverse()));
        }
开发者ID:zdzdz,项目名称:Data-Structures-and-Algorithms-HW,代码行数:40,代码来源:Startup.cs

示例7: Main

        static void Main()
        {
            var sequence = new Queue<int>();
            Console.WriteLine("Enter N: ");
            var start = int.Parse(Console.ReadLine());
            Console.WriteLine("Enter M: ");
            var end = int.Parse(Console.ReadLine());

            var numbers = new Queue<int>();

            while (start <= end)
            {
                numbers.Enqueue(end);

                if (end / 2 >= start)
                {
                    if (end % 2 == 0)
                    {
                        end /= 2;
                    }
                    else
                    {
                        end--;
                    }
                }
                else
                {
                    if (end - 2 >= start)
                    {
                        end -= 2;
                    }
                    else
                    {
                        end--;
                    }
                }
            }

            Console.WriteLine(string.Join(" -> ", numbers.Reverse()));
        }
开发者ID:NK-Hertz,项目名称:Telerik-Academy-2015,代码行数:40,代码来源:ShortestSequenceOfOperations.cs

示例8: Main

        public static void Main()
        {
            //int n = ConsoleTool.ReadInteger();
            //int m = ConsoleTool.ReadInteger();
            int n = 5;
            int m = 16;

            Queue<int> queue = new Queue<int>();

            while (n <= m)
            {
                queue.Enqueue(m);

                if (m / 2 >= n)
                {
                    if (m % 2 == 0)
                    {
                        m /= 2;
                    }
                    else
                    {
                        m--;
                    }
                }
                else
                {
                    if (m - 2 >= n)
                    {
                        m -= 2;
                    }
                    else
                    {
                        m--;
                    }
                }
            }

            Console.WriteLine(string.Join(",", queue.Reverse()));
        }
开发者ID:AndrewMitev,项目名称:Telerik-Academy,代码行数:39,代码来源:Startup.cs

示例9: Main

        public static void Main()
        {
            Console.Write("Enter n: ");
            int n = int.Parse(Console.ReadLine());
            Console.Write("Enter m: ");
            int m = int.Parse(Console.ReadLine());

            Queue<int> queue = new Queue<int>();
            while (n <= m)
            {
                queue.Enqueue(m);

                if (m / 2 >= n)
                {
                    if (m % 2 == 0)
                    {
                        m /= 2;
                    }
                    else
                    {
                        m--;
                    }
                }
                else
                {
                    if (m - 2 >= n)
                    {
                        m -= 2;
                    }
                    else
                    {
                        m--;
                    }
                }
            }

            Console.WriteLine(string.Join(" --> ", queue.Reverse()));
        }
开发者ID:MarinaGeorgieva,项目名称:TelerikAcademy,代码行数:38,代码来源:Startup.cs

示例10: Main

        public static void Main()
        {
            var result = new Queue<int>();

            int start = 5;
            int end = 16;

            while (start <= end)
            {
                result.Enqueue(end);

                if (end / 2 >= start)
                {
                    if (end % 2 == 0)
                    {
                        end /= 2;
                    }
                    else
                    {
                        end--;
                    }
                }
                else
                {
                    if (end - 2 >= start)
                    {
                        end -= 2;
                    }
                    else
                    {
                        end--;
                    }
                }
            }

            Console.WriteLine(string.Join(" -> ", result.Reverse()));
        }
开发者ID:danisio,项目名称:DataStructuresAndAlgorithms-Homeworks,代码行数:37,代码来源:Startup.cs

示例11: StartTempLogging


//.........这里部分代码省略.........
              rs = BuildDatabase(alldata.Where(x => x.Log).ToList());
            }

            initialized = true;
              }

              if (logmode)
              {
            RecordSample(rs, alldata);
              }

              if (dumpmode)
              {
            using (var w = new StringWriter())
            {
              mon.DumpRawByteData(w);
              File.AppendAllText("W83627DHG.log", w.ToString());
            }

            using (var w = new StringWriter())
            {
              mon.DumpSIOByteData(w);
              File.AppendAllText("Super-IO.log", w.ToString());
            }

            //using (var w = new StringWriter())
            //{
            //  asp0800.DumpRawByteData(w);
            //  File.AppendAllText("ASP0800b.log", w.ToString());
            //}

            using (var w = new StringWriter())
            {
              asp0800.DumpRawWordData(w);
              File.AppendAllText("ASP0800w.log", w.ToString());
            }
              }

              if (consolemode)
              {
            Console.Title = string.Format("TempServe - Running for: {3}d {0:00}:{1:00}:{2:00}",
              elapsed.Hours, elapsed.Minutes, elapsed.Seconds, elapsed.Days);

            while (avg5.Count >= 60)
            {
              avg5.Dequeue();
            }

            var hashdata = alldata.ToDictionary(x => x.Name, x => x); ;

            avg5.Enqueue(hashdata);

            if (min == null)
            {
              min = hashdata;
            }
            else
            {
              min = HashMap((x, y) => x.Value > y.Value ? y : x, min, hashdata);
            }

            if (max == null)
            {
              max = hashdata;
            }
            else
            {
              max = HashMap((x, y) => x.Value < y.Value ? y : x, max, hashdata);
            }

            using (var output = new StringWriter())
            {
              output.WriteLine("{0,-18}{1,10}{2,10}{3,10}{4,10}{5,10}{6,10}",
                "Sensor", "Current", "Min", "Max", "Avg(10)", "Avg(30)", "Avg(60)");

              foreach (var s in alldata)
              {
                var avg = avg5.Reverse().ToArray();

                var fs = BuildFormatString(s);

                output.WriteLine(fs, s.Name, s.Value,
                  min[s.Name].Value,
                  max[s.Name].Value,
                  avg.Take(10).Select(x => x[s.Name]).Average(x => x.Value),
                  avg.Take(30).Select(x => x[s.Name]).Average(x => x.Value),
                  avg.Take(60).Select(x => x[s.Name]).Average(x => x.Value)
                  );
              }

              Console.Clear();
              Console.Write(output.ToString());
            }
              }

              var taken = Math.Min((sw.Elapsed - elapsed).TotalMilliseconds, 100) + 3;
              Thread.Sleep(1000 - (int)taken);
            }
              }
        }
开发者ID:Chinoyan,项目名称:TempServe,代码行数:101,代码来源:TempLogger.cs

示例12: createPathFromQueue

 /// <summary>
 /// Convert the path from dijkstra algorithm to fit natural version from start node to finish node
 /// </summary>
 private static void createPathFromQueue(List<List<int>> visited, out List<int> path, int node, int startNode)
 {
     Queue<int> q = new Queue<int>();
     Queue<int> qtemp = new Queue<int>();
     q.Enqueue(node);
     while (true)
     {
         node = visited[node][0];
         q.Enqueue(node);
         if (node == startNode)
         {
             break;
         }
     }
     path = q.Reverse().ToList<int>();
 }
开发者ID:gipsiarek,项目名称:cop-robber,代码行数:19,代码来源:Tests.xaml.cs

示例13: FindShortestSeqOfOperationFromNToM

        // 10.
        public void FindShortestSeqOfOperationFromNToM(int start, int end)
        {
            var queue = new Queue<int>();
            while (start != end)
            {
                queue.Enqueue(end);
                if (end / 2 >= start)
                {
                    if (end % 2 == 0)
                    {
                        end /= 2;
                    }
                    else
                    {
                        end--;
                    }
                }
                else
                {
                    if (end - 2 >= start)
                    {
                        end -= 2;
                    }
                    else
                    {
                        end--;
                    }
                }
            }

            queue.Enqueue(start);
            Console.WriteLine(string.Join(", ", queue.Reverse()));
        }
开发者ID:TeeeeeC,项目名称:TelerikAcademy2015-2016,代码行数:34,代码来源:Operation.cs

示例14: reconstruct_path

    void reconstruct_path(
		Dictionary<Path_Node<Tile>, Path_Node<Tile>> Came_From,
		Path_Node<Tile> current
	)
    {
        // So at this point, current IS the goal.
        // So what we want to do is walk backwards through the Came_From
        // map, until we reach the "end" of that map...which will be
        // our starting node!
        Queue<Tile> total_path = new Queue<Tile>();
        total_path.Enqueue(current.data); // This "final" step is the path is the goal!

        while( Came_From.ContainsKey(current) ) {
            // Came_From is a map, where the
            //    key => value relation is real saying
            //    some_node => we_got_there_from_this_node

            current = Came_From[current];
            total_path.Enqueue(current.data);
        }

        // At this point, total_path is a queue that is running
        // backwards from the END tile to the START tile, so let's reverse it.

        path = new Queue<Tile>( total_path.Reverse() );
    }
开发者ID:ConorGrocock,项目名称:Project_Porcupine,代码行数:26,代码来源:Path_AStar.cs

示例15: ComparePad

        private bool ComparePad(Queue<cmd> queue)
        {
            int ipos = padtag.Count - 1;
            if (ipos < 0) return false;
            int iseek = 1;
            int lastpad = 0;
            int pd = 0;
            foreach (cmd p in queue.Reverse())
            {

                if (p.padtag == lastpad) continue;      //1.输入冗余过滤
                lastpad = p.padtag;

                if (p.padtag == 5)                      //2.无输入冗余过滤
                {
                    if (padtag[ipos] == 5) ipos--;//输入要求空
                    if (ipos < 0) return true;
                    continue;//无方向,跳过
                }

                if (ipos < padtag.Count - 1)
                {
                    if (padtag[ipos + 1] == p.padtag)   //3.简化操作判定
                    {//相容引起的重复可以跳
                        if(pd>0)
                            continue;//重复方向,跳过

                    }
                }

                pd = PadDist(padtag[ipos], p.padtag);
                if (pd > 1) return false;
                ipos--;
                if (ipos < 0) return true;
                if (pd == 0)//相等
                {
                    iseek = 0;
                    //ipos--;
                }
                else//相容                            //3.简化操作判定,斜方向可以简化两个方向
                {
                    int irpd=0;
                    if(ipos+2<padtag.Count)
                        irpd = padtag[ipos + 2];      //3.1同一个四分之一圆里来回不能简化
                    if (iseek == 0)
                    {
                        pd = PadDist(padtag[ipos], p.padtag);
                        if (pd <= 1)
                        {
                            iseek = 0;
                            if (padtag[ipos] != irpd)
                            {
                                ipos--;
                                if (ipos < 0) return true;
                            }
                        }
                    }
                    iseek++;
                    if (iseek > 1)   iseek = 0;
                }

            }
            return false;
        }
开发者ID:Gaopest,项目名称:fightclub,代码行数:64,代码来源:controlutil.cs


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