本文整理汇总了C#中ItemCollection.AddRange方法的典型用法代码示例。如果您正苦于以下问题:C# ItemCollection.AddRange方法的具体用法?C# ItemCollection.AddRange怎么用?C# ItemCollection.AddRange使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ItemCollection
的用法示例。
在下文中一共展示了ItemCollection.AddRange方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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));
}
示例2: 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);
}
示例3: Test_sorting_update_nonsort_property_retains_order
public void Test_sorting_update_nonsort_property_retains_order()
{
var item1 = new ActivityMonitorComponent.WorkItem(new WorkItemData { Identifier = 1, Status = WorkItemStatusEnum.Pending, Priority = WorkItemPriorityEnum.Normal });
var item2 = new ActivityMonitorComponent.WorkItem(new WorkItemData { Identifier = 2, Status = WorkItemStatusEnum.Pending, Priority = WorkItemPriorityEnum.Normal });
var item3 = new ActivityMonitorComponent.WorkItem(new WorkItemData { Identifier = 3, Status = WorkItemStatusEnum.Pending, Priority = WorkItemPriorityEnum.Normal });
var item4 = new ActivityMonitorComponent.WorkItem(new WorkItemData { Identifier = 4, Status = WorkItemStatusEnum.Pending, Priority = WorkItemPriorityEnum.Normal });
var item5 = new ActivityMonitorComponent.WorkItem(new WorkItemData { Identifier = 5, Status = WorkItemStatusEnum.Pending, Priority = WorkItemPriorityEnum.Normal });
var items = new ItemCollection<ActivityMonitorComponent.WorkItem>();
items.AddRange(new[] { item1, item2, item3, item4, item5 });
// the idea here is that if an item is updated, but the sorty property (Status) has not changed,
// then the item does not move around in the list, but is updated in place
var manager = new ActivityMonitorComponent.WorkItemUpdateManager(items, NoFilter, () => { });
// item 1 Priority changes - should not cause a change in list order
var x = new ActivityMonitorComponent.WorkItem(new WorkItemData { Identifier = 1, Status = WorkItemStatusEnum.Pending, Priority = WorkItemPriorityEnum.Stat});
manager.Update(new[] { x }, StatusComparison);
Assert.IsTrue(items.SequenceEqual(new[] { item1, item2, item3, item4, item5 }));
// item 4 Priority changes - should not cause a change in list order
var y = new ActivityMonitorComponent.WorkItem(new WorkItemData { Identifier = 4, Status = WorkItemStatusEnum.Pending, Priority = WorkItemPriorityEnum.High});
manager.Update(new[] { y }, StatusComparison);
Assert.IsTrue(items.SequenceEqual(new[] { item1, item2, item3, item4, item5 }));
}
示例4: ClassificationEnsembleSolution
public ClassificationEnsembleSolution(IEnumerable<IClassificationModel> models, IClassificationProblemData problemData, IEnumerable<IntRange> trainingPartitions, IEnumerable<IntRange> testPartitions)
: base(new ClassificationEnsembleModel(Enumerable.Empty<IClassificationModel>()), new ClassificationEnsembleProblemData(problemData)) {
this.trainingPartitions = new Dictionary<IClassificationModel, IntRange>();
this.testPartitions = new Dictionary<IClassificationModel, IntRange>();
this.classificationSolutions = new ItemCollection<IClassificationSolution>();
List<IClassificationSolution> solutions = new List<IClassificationSolution>();
var modelEnumerator = models.GetEnumerator();
var trainingPartitionEnumerator = trainingPartitions.GetEnumerator();
var testPartitionEnumerator = testPartitions.GetEnumerator();
while (modelEnumerator.MoveNext() & trainingPartitionEnumerator.MoveNext() & testPartitionEnumerator.MoveNext()) {
var p = (IClassificationProblemData)problemData.Clone();
p.TrainingPartition.Start = trainingPartitionEnumerator.Current.Start;
p.TrainingPartition.End = trainingPartitionEnumerator.Current.End;
p.TestPartition.Start = testPartitionEnumerator.Current.Start;
p.TestPartition.End = testPartitionEnumerator.Current.End;
solutions.Add(modelEnumerator.Current.CreateClassificationSolution(p));
}
if (modelEnumerator.MoveNext() | trainingPartitionEnumerator.MoveNext() | testPartitionEnumerator.MoveNext()) {
throw new ArgumentException();
}
trainingEvaluationCache = new Dictionary<int, double>(problemData.TrainingIndices.Count());
testEvaluationCache = new Dictionary<int, double>(problemData.TestIndices.Count());
RegisterClassificationSolutionsEventHandler();
classificationSolutions.AddRange(solutions);
}