本文整理汇总了C#中MultiDimensionalArray.AddRange方法的典型用法代码示例。如果您正苦于以下问题:C# MultiDimensionalArray.AddRange方法的具体用法?C# MultiDimensionalArray.AddRange怎么用?C# MultiDimensionalArray.AddRange使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MultiDimensionalArray
的用法示例。
在下文中一共展示了MultiDimensionalArray.AddRange方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetLastValueSmallerThanShouldBeFast
public void GetLastValueSmallerThanShouldBeFast()
{
int amount = 1000000;
List<double> values = new List<double>(amount);
for (int i = 0; i < amount; i++)
values.Add(i);
var array = new MultiDimensionalArray();
array.AddRange(values);
TestHelper.AssertIsFasterThan(500, () =>
{
for (int i = 0; i < 100000; i++)
FunctionHelper.GetLastValueSmallerThan(55555.0, array);
});
//orig: 2100ms
}
示例2: MinAndMaxValue
public void MinAndMaxValue()
{
IMultiDimensionalArray array = new MultiDimensionalArray<int>();
array.AddRange(new[] { 1, 2, 3 });
Assert.AreEqual(1, array.MinValue);
Assert.AreEqual(3, array.MaxValue);
array = new MultiDimensionalArray<double>();
array.AddRange(new[] { 1.0d, 2.0d, 3.0d });
Assert.AreEqual(1.0d, array.MinValue);
Assert.AreEqual(3.0d, array.MaxValue);
array = new MultiDimensionalArray<float>();
array.AddRange(new[] { 1.0f, 2.0f, 3.0f });
Assert.AreEqual(1.0f, array.MinValue);
Assert.AreEqual(3.0f, array.MaxValue);
array = new MultiDimensionalArray(2, 2);
array[0, 0] = -2;
array[0, 1] = 5;
Assert.AreEqual(-2, array.MinValue);
Assert.AreEqual(5, array.MaxValue);
}
示例3: AddUnsortedRangeGivesException
public void AddUnsortedRangeGivesException()
{
IMultiDimensionalArray<double> array = new MultiDimensionalArray<double>()
{IsAutoSorted = true};
//not sorted..should throw
array.AddRange(new[] {5.0, 2.0, 3.0});
}
示例4: AddRangeToSortedArrayThrowsExceptionIfRangeContainsValuesSmallerThenMaxValue
public void AddRangeToSortedArrayThrowsExceptionIfRangeContainsValuesSmallerThenMaxValue()
{
IMultiDimensionalArray<double> array = new MultiDimensionalArray<double>(new[] {1.0, 2.0, 3.0}, new[] {3}){IsAutoSorted = true};
array.AddRange(new[]{0.0,2.0,3.0});
}
示例5: PerformanceRemoveValues
public void PerformanceRemoveValues()
{
IMultiDimensionalArray<double> array = new MultiDimensionalArray<double>();
const int valuesToRemove = 200000;
var values = Enumerable.Range(1, valuesToRemove).Select(Convert.ToDouble).ToArray();
array.AddRange(values);
TestHelper.AssertIsFasterThan(95000, () => values.ForEach(d => array.Remove(d))); //too slow
}
示例6: PerformanceAddValues
public void PerformanceAddValues()
{
IMultiDimensionalArray<double> array = new MultiDimensionalArray<double>();
const int valuesToAdd = 200000;
var valuesToAddArray = Enumerable.Range(1, valuesToAdd).Select(Convert.ToDouble).ToArray();
array.AddRange(valuesToAddArray); //warmup caches
array.Clear();
TestHelper.AssertIsFasterThan(110, () =>
array.AddRange(valuesToAddArray));
}