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


C# Queue.OrderByDescending方法代码示例

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


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

示例1: Main

        static void Main(string[] args)
        {
            CpuMonitor monitor = new CpuMonitor();

            Queue<float> measures = new Queue<float>();

            Console.Write("Trying to detect StarCraft crash...");

            while (true)
            {
                Thread.Sleep(500);
                measures.Enqueue(monitor.getCurrentCpuUsage());

                if (measures.Count == 20)
                {
                    List<float> l = measures.OrderByDescending(i => i).ToList();
                    if (l[0] < 25)
                    {
                        Console.WriteLine("Crash detected!");
                        Console.WriteLine("Taking screenshot of crash..");
                        TakeScreenShot();

                        string[] data = File.ReadAllLines(@"C:\Users\admin\Desktop\StarCraft\StarCraft\Starcraft\output.txt");

                        Console.WriteLine("Reading output file..");
                        string replay = data[data.Length - 1].Split(',')[1];

                        Console.WriteLine("Replay " + replay + " caused the crash!");
                        Process.GetProcesses().First(i => i.ProcessName == "StarCraft").Kill();

                        Console.WriteLine("Starcraft process killed!");
                        Thread.Sleep(500);

                        File.Delete(@"C:\Users\admin\Desktop\StarCraft\StarCraft\Starcraft\maps\replays\" + replay);
                        Console.WriteLine("Bad Replay deleted");

                        File.Delete(@"C:\Users\admin\Desktop\StarCraft\StarCraft\Starcraft\output.txt");
                        Console.WriteLine("output.txt deleted");

                        Process.Start(@"C:\Users\admin\Desktop\StarCraft\StarCraft\Chaoslauncher\Chaoslauncher.exe");
                        Console.WriteLine("Chaoslauncher started!");

                        Thread.Sleep(5000);
                        SimulateEnter();
                        Console.WriteLine("Simulated enter click!");
                        Thread.Sleep(60000);
                        SimulateEnter();
                        Console.WriteLine("Simulated enter click!");
                        Thread.Sleep(60000 * 2);
                        Console.Write("Trying to detect StarCraft crash...");
                    }
                    measures.Clear();
                }
            }

            Console.ReadLine();
        }
开发者ID:steffan88,项目名称:StarcraftPreprocessor,代码行数:57,代码来源:Program.cs

示例2: Frm_Main_Load

 private void Frm_Main_Load(object sender, EventArgs e)
 {
     Queue<UserInfo> users = new Queue<UserInfo>();//创建泛型队列
     for (int i = 0; i < 10; i++)//为泛型队列添加元素
     {
         users.Enqueue(new UserInfo(i < 5 ? 0 : 1, "User0" + i.ToString(), "0" + i.ToString()));
     }
     //将泛型队列按用户名降序排列
     var query = users.OrderByDescending(itm => itm.UserName);
     label1.Text = "显示查询结果:\n";
     foreach (var item in query)//显示查询结果
     {
         label1.Text += string.Format("({0},{1})", item.UserCode, item.UserName);
         label1.Text += "\n";
     }
 }
开发者ID:mahuidong,项目名称:c-1200-II,代码行数:16,代码来源:Frm_Main.cs

示例3: splitBoxes

        /**
         * Iterate through the {@link java.util.Queue}, popping
         * {@link ColorCutQuantizer.Vbox} objects from the queue
         * and splitting them. Once split, the new box and the remaining box are offered back to the
         * queue.
         *
         * @param queue {@link java.util.PriorityQueue} to poll for boxes
         * @param maxSize Maximum amount of boxes to split
         */
        private Queue<Vbox> splitBoxes(Queue<Vbox> queue, int maxSize)
        {
            while (queue.Count < maxSize)
            {
                queue = new Queue<Vbox>(queue.OrderByDescending(v => v.getVolume()));
                Vbox vbox = queue.Dequeue();

                if (vbox != null && vbox.canSplit())
                {
                    // First split the box, and offer the result
                    queue.Enqueue(vbox.splitBox());
                    // Then offer the box back
                    queue.Enqueue(vbox);
                }
                else
                {
                    break;
                }
            }

            queue = new Queue<Vbox>(queue.OrderBy(v => v.getVolume()));
            return queue;
        }
开发者ID:renewal-wu,项目名称:PaletteSample,代码行数:32,代码来源:ColorCutQuantizer.cs


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