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


C# KeyValuePair.OrderBy方法代码示例

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


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

示例1: InitializeGroups

        /// <summary>
        ///   Initializes the mmi groups with starting elements that have the highest unconditional entropy
        /// </summary>
        protected void InitializeGroups()
        {
            // Clear all groups
            for (int i = 0; i < minimalMutualInfoGroups.Length; i++)
            {
                minimalMutualInfoGroups[i].Clear();
            }

            // Compute unconditional entropy
            KeyValuePair<int, double>[] uncodEntropy = new KeyValuePair<int, double>[NeuralNetworkEnsembleDimensionality];
            for (int i = 0; i < NeuralNetworkEnsembleDimensionality; i++)
            {
                double uncodEntrpy = 0.0;
                List<MinimalMutualInfoPair> list = mmiPairs.FindAll(pair => pair.IndexFirst == i || pair.IndexSecond == i);
                foreach (MinimalMutualInfoPair pair in list)
                {
                    uncodEntrpy += pair.MutualInformation;
                }

                uncodEntropy[i] = new KeyValuePair<int, double>(i, uncodEntrpy);
            }

            List<KeyValuePair<int, double>> query = new List<KeyValuePair<int, double>>(uncodEntropy.OrderBy(kv => kv.Value));

            // Assign elements that have highest unconditional entropy
            for (int i = 0; i < minimalMutualInfoGroups.Length; i++)
            {
                minimalMutualInfoGroups[i].AddToGroup(query[i].Key);
                indexList.Remove(query[i].Key);
            }
        }
开发者ID:remy22,项目名称:soundfingerprinting,代码行数:34,代码来源:MinimalMutualInfoPattern.cs

示例2: Start_Click

 protected void Start_Click(object sender, EventArgs e)
 {
     KeyValuePair<int, string>[] stubarray = new KeyValuePair<int, string>[4];
     for (int i = 0; i < stubarray.Length; i++)
     {
         stubarray[i] = colors[i + 1];
     }
     Label1.Text = "Turn: 0";
     Button1.CssClass = colors[0].Value;
     Button2.CssClass = colors[0].Value;
     Button3.CssClass = colors[0].Value;
     Button4.CssClass = colors[0].Value;
     Button1.Visible = true;
     Button2.Visible = true;
     Button3.Visible = true;
     Button4.Visible = true;
     Random rnd = new Random(System.DateTime.Now.Millisecond);
     KeyValuePair<int, string>[] MyRandomArray = stubarray.OrderBy(x => rnd.Next()).ToArray();
     Enigma0.CssClass = MyRandomArray[0].Value;
     Label6.Text = MyRandomArray[0].Key.ToString();
     Enigma1.CssClass = MyRandomArray[1].Value;
     Label7.Text = MyRandomArray[1].Key.ToString();
     Enigma2.CssClass = MyRandomArray[2].Value;
     Label8.Text = MyRandomArray[2].Key.ToString();
     Enigma3.CssClass = MyRandomArray[3].Value;
     Label9.Text = MyRandomArray[3].Key.ToString();
     GuessButton.Enabled = true;
     Enigma0.Visible = false;
     Enigma1.Visible = false;
     Enigma2.Visible = false;
     Enigma3.Visible = false;
     StartButton.Enabled = false;
 }
开发者ID:McArren,项目名称:ASPColorGame,代码行数:33,代码来源:Game.aspx.cs

示例3: ArrangeOverride

        protected override Size ArrangeOverride(Size finalSize)
        {
            KeyValuePair<double, int>[] flowLength = new KeyValuePair<double, int>[groupcount];
            double flowWidth = finalSize.Width / groupcount;
            double[] xWidth = new double[groupcount];
            foreach (int index in Enumerable.Range(0, groupcount))
            {
                flowLength[index] = new KeyValuePair<double, int>(0.0, index);
                xWidth[index] = index * flowWidth;
            }

            foreach (UIElement childElem in Children)
            {
                // 获取子控件期望大小
                Size elemSize = childElem.DesiredSize;
                double elemLength = elemSize.Height;

                //得到最短流长度
                var pair = flowLength[0];
                double chosenFlowHeight = pair.Key;
                int chosenFlowIdx = pair.Value;

                // 设置即将放置的控件坐标
                Point pt = new Point(xWidth[chosenFlowIdx], chosenFlowHeight);

                // 调用Arrange进行子控件布局。并让子控件利用上整个流的长度。
                childElem.Arrange(new Rect(pt, new Size(flowWidth, elemSize.Height)));

                // 重新计算最短流。
                flowLength[0] = new KeyValuePair<double, int>(chosenFlowHeight + elemLength, chosenFlowIdx);
                flowLength = flowLength.OrderBy(p => p.Key).ToArray();
            }
            return finalSize;
        }
开发者ID:aurora-lzzp,项目名称:com.aurora.aumusic,代码行数:34,代码来源:AlbumFlowPage.xaml.cs

示例4: get_DiskUsageInfo

        private string get_DiskUsageInfo()
        {
            StringBuilder sb = new StringBuilder();

            KeyValuePair<string, string>[] dirs = new KeyValuePair<string, string>[]
            {
                new KeyValuePair<string, string>("Thumbnails", Program.thumb_save_dir),
                new KeyValuePair<string, string>("Full files", Program.file_save_dir),
                new KeyValuePair<string, string>("API Cached files", Program.api_cache_dir ),
                new KeyValuePair<string, string>("Post files", Program.post_files_dir),
               // new KeyValuePair<string, string>("Temporary files", Program.temp_files_dir),
            };

            foreach (KeyValuePair<string, string> a in dirs.OrderBy(x => x.Key))
            {
                DirectoryStatsEntry ds = FileSystemStats.GetDirStats(a.Value);

                if (ds != null)
                {
                    sb.Append("<tr>");
                    sb.AppendFormat("<td>{0}</td>", ds.FileCount);
                    sb.AppendFormat("<td>{0}</td>", a.Key);
                    sb.AppendFormat("<td>{0}</td>", Program.format_size_string(ds.TotalSize));
                    sb.AppendFormat("<td>{0}</td>", Program.format_size_string(ds.AverageFileSize));
                    sb.AppendFormat("<td>{0}</td>", Program.format_size_string(ds.LargestFile));
                    sb.AppendFormat("<td>{0}</td>", Program.format_size_string(ds.SmallestFile));
                    sb.Append("</tr>");
                }
            }

            return sb.ToString();
        }
开发者ID:tyzmodo,项目名称:chan-archiver,代码行数:32,代码来源:OverviewPageHandler.cs

示例5: MeasureOverride

        protected override Size MeasureOverride(Size availableSize)
        {
            //横向瀑布流

            groupcount = (int)availableSize.Width / 256 >= 3 ? (int)availableSize.Width / 256 : 3;
            //三组流长度记录
            KeyValuePair<double, int>[] flowLength = new KeyValuePair<double, int>[groupcount];
            foreach (int index in Enumerable.Range(0, groupcount))
            {
                flowLength[index] = new KeyValuePair<double, int>(0.0, index);
            }

            //每组长度为总长度1/3
            double flowWidth = availableSize.Width / groupcount;

            //子控件宽为组宽,长无限制
            Size childMeasureSize = new Size(flowWidth, double.PositiveInfinity);

            //子控件遍历计算长度
            foreach (UIElement childElement in Children)
            {
                childElement.Measure(childMeasureSize);
                Size childSize = childElement.DesiredSize;
                //得到子控件长
                double childLength = childSize.Height;
                //暂存最短流长度
                var tempPair = flowLength[0];
                //最短流长度重新计算
                flowLength[0] = new KeyValuePair<double, int>(tempPair.Key + childLength, tempPair.Value);
                //重新按流长度排列键值对        这里以Key 的值作为排列依据,flowWidth[0]为Key最小的键值对,P可替换为任意字母
                flowLength = flowLength.OrderBy(P => P.Key).ToArray();
            }
            //返回 长:最长流的长;宽:传入的宽
            return new Size(availableSize.Width, flowLength.Last().Key);
        }
开发者ID:aurora-lzzp,项目名称:com.aurora.aumusic,代码行数:35,代码来源:AlbumFlowPage.xaml.cs


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