本文整理汇总了C#中SortedDictionary.HasSeveralItems方法的典型用法代码示例。如果您正苦于以下问题:C# SortedDictionary.HasSeveralItems方法的具体用法?C# SortedDictionary.HasSeveralItems怎么用?C# SortedDictionary.HasSeveralItems使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SortedDictionary
的用法示例。
在下文中一共展示了SortedDictionary.HasSeveralItems方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: HasSeveralItemsArrayPredicate
public void HasSeveralItemsArrayPredicate()
{
var x = Enumerable.Range(1, 1024).ToArray();
var y = Enumerable.Range(1, 1024).Select(a => new Tuple<int, int>(a,a)).ToArray();
var z = Enumerable.Range(1, 1024).Select(a => new { A = a}).ToArray();
var dict = new SortedDictionary<int, int>(x.ToDictionary(a => a, a => a));
Assert.IsTrue(x.HasSeveralItems(10, val => val%3 == 0));
Assert.IsTrue(x.HasSeveralItems(300, val => val%3 == 0));
Assert.IsFalse(x.HasSeveralItems(1025, val => val%3 == 0));
Assert.IsTrue(y.HasSeveralItems(10, val => val.Item1%3 == 0));
Assert.IsTrue(y.HasSeveralItems(300, val => val.Item1%3 == 0));
Assert.IsFalse(y.HasSeveralItems(1025, val => val.Item1%3 == 0));
Assert.IsTrue(z.HasSeveralItems(10, val => val.A%3 == 0));
Assert.IsTrue(z.HasSeveralItems(300, val => val.A%3 == 0));
Assert.IsFalse(z.HasSeveralItems(1025, val => val.A%3 == 0));
Assert.IsTrue(dict.HasSeveralItems(10, val => val.Key%3 == 0));
Assert.IsTrue(dict.HasSeveralItems(300, val => val.Key%3 == 0));
Assert.IsFalse(dict.HasSeveralItems(1025, val => val.Key%3 == 0));
}
示例2: HasSeveralItemsArray
public void HasSeveralItemsArray()
{
var x = Enumerable.Range(1, 1024).ToArray();
var y = Enumerable.Range(1, 1024).Select(a => new Tuple<int, int>(a,a)).ToArray();
var z = Enumerable.Range(1, 1024).Select(a => new { A = a}).ToArray();
var dict = new SortedDictionary<int, int>(x.ToDictionary(a => a, a => a));
Assert.IsTrue(x.HasSeveralItems(10));
Assert.IsTrue(x.HasSeveralItems(1000));
Assert.IsFalse(x.HasSeveralItems(1025));
Assert.IsTrue(y.HasSeveralItems(10));
Assert.IsTrue(y.HasSeveralItems(1000));
Assert.IsFalse(y.HasSeveralItems(1025));
Assert.IsTrue(z.HasSeveralItems(10));
Assert.IsTrue(z.HasSeveralItems(1000));
Assert.IsFalse(z.HasSeveralItems(1025));
Assert.IsTrue(dict.HasSeveralItems(10));
Assert.IsTrue(dict.HasSeveralItems(1000));
Assert.IsFalse(dict.HasSeveralItems(1025));
}