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


C# ReadOnlyCollection.OrderBy方法代码示例

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


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

示例1: AssertHelper

		bool AssertHelper(ReadOnlyCollection<NameBindingWithFilling> oneOfTheResults, IList<Expectation> expectations)
		{
			//orders names by leafIndex (both of the expectation and results) and then compares whether they have the same elements (which then need to be in the same order, hence SequenceEquals suffices)
			//Otherwise we have to correlate the order of both sequence we have to compare
			var orderedExpectations = expectations.OrderBy(e => e.ExpectedLeafIndex);
			var orderedResult = oneOfTheResults.OrderBy(match => match.Binding.Index);

			var namesMatch = Enumerable.SequenceEqual(orderedExpectations.Select(e => e.ExpectedName), orderedResult.Select(m => m.Binding.Name), GloballyScopedMethods.ReferenceEqualityComparer);
			var leafIndicesMatch = Enumerable.SequenceEqual(orderedExpectations.Select(e => e.ExpectedLeafIndex), orderedResult.Select(m => m.Binding.Index));

			return namesMatch && leafIndicesMatch;
		}
开发者ID:JeroenBos,项目名称:ASDE,代码行数:12,代码来源:NameBindingTests.cs

示例2: orderAllResults

        //TODO: This won't be necessary when we enforce precise location
        private List<RecognizedSegment> orderAllResults(ReadOnlyCollection<RecognizedSegment> results)
        {
            var sortedOutput = results.OrderBy(k => k.Bounds.Y).ToList();
            int indiciesToAdjust = 0;

            for (int i = sortedOutput.Count - 1; i >= 0; i--) {
                if (i != 0 && (sortedOutput[i].Bounds.Y - sortedOutput[i - 1].Bounds.Y) < 4) {
                    indiciesToAdjust++;
                }
                else {
                    for (int j = 1; j <= indiciesToAdjust; j++) {
                        System.Drawing.Rectangle newBounds = new System.Drawing.Rectangle(sortedOutput[i + j].Bounds.X,
                                                                                            sortedOutput[i].Bounds.Y,
                                                                                            sortedOutput[i + j].Bounds.Width,
                                                                                            sortedOutput[i + j].Bounds.Height);
                        sortedOutput[i + j] = new RecognizedSegment(newBounds, sortedOutput[i + j].Text, sortedOutput[i + j].Certainty);
                    }
                    indiciesToAdjust = 0;
                }
            }

            sortedOutput = sortedOutput.OrderByDescending(k => k.Bounds.Width)
                                        .OrderBy(k => k.Bounds.X)
                                        .OrderBy(k => k.Bounds.Y).ToList();
            return sortedOutput;
        }
开发者ID:Amichai,项目名称:Prax,代码行数:27,代码来源:OutputRenderer.cs

示例3: RandomizedList

 public static IEnumerable<Player> RandomizedList(ReadOnlyCollection<Player> players)
 {
     List<Player> randomPlayers = new List<Player>();
     randomPlayers.AddRange(players.OrderBy(x => r.Next()).Take(players.Count));
     return randomPlayers;
 }
开发者ID:jkissinger,项目名称:GmailGameNarrator,代码行数:6,代码来源:MathX.cs


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