本文整理汇总了C#中ItemCollection.FindInsertionPoint方法的典型用法代码示例。如果您正苦于以下问题:C# ItemCollection.FindInsertionPoint方法的具体用法?C# ItemCollection.FindInsertionPoint怎么用?C# ItemCollection.FindInsertionPoint使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ItemCollection
的用法示例。
在下文中一共展示了ItemCollection.FindInsertionPoint方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Test_FindInsertionPoint_empty_list
public void Test_FindInsertionPoint_empty_list()
{
var items = new ItemCollection<Foo>();
var comparison = new Comparison<Foo>((x, y) => string.CompareOrdinal(x.Name, y.Name));
// insertion point is always zero
Assert.AreEqual(0, items.FindInsertionPoint(new Foo("a"), comparison));
Assert.AreEqual(0, items.FindInsertionPoint(new Foo("d"), comparison));
}
示例2: Test_FindInsertionPoint_non_existant_item
public void Test_FindInsertionPoint_non_existant_item()
{
var items = new ItemCollection<Foo>();
items.AddRange(new []{ new Foo("b"), new Foo("b"), new Foo("d")});
var comparison = new Comparison<Foo>((x, y) => string.CompareOrdinal(x.Name, y.Name));
Assert.AreEqual(0, items.FindInsertionPoint(new Foo("a"), comparison));
Assert.AreEqual(2, items.FindInsertionPoint(new Foo("c"), comparison));
Assert.AreEqual(3, items.FindInsertionPoint(new Foo("e"), comparison));
}
示例3: Test_FindInsertionPoint_non_existing_item
public void Test_FindInsertionPoint_non_existing_item()
{
var items = new ItemCollection<Foo>();
items.AddRange(new[] { new Foo("b"), new Foo("b"), new Foo("d") });
var comparison = new Comparison<Foo>((x, y) => string.CompareOrdinal(x.Name, y.Name));
var b = items.FindInsertionPoint(new Foo("b"), comparison);
Assert.IsTrue(b == 0 || b == 1);
var d = items.FindInsertionPoint(new Foo("d"), comparison);
Assert.IsTrue(d == 2);
}