本文整理汇总了C#中DoubleVector.SetRange方法的典型用法代码示例。如果您正苦于以下问题:C# DoubleVector.SetRange方法的具体用法?C# DoubleVector.SetRange怎么用?C# DoubleVector.SetRange使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DoubleVector
的用法示例。
在下文中一共展示了DoubleVector.SetRange方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
//.........这里部分代码省略.........
throw new Exception("RemoveAt test (2) failed");
} catch (ArgumentOutOfRangeException) {
}
for (int i=0; i<collectionSize; i++) {
if (vect[i] != i*10.1)
throw new Exception("RemoveAt test (3) failed, index:" + i);
}
{
// Capacity test
try {
myDoubleVector = new DoubleVector(-1);
throw new Exception("constructor setting capacity (1) test failed");
} catch (ArgumentOutOfRangeException) {
}
DoubleVector dv = new DoubleVector(10);
if (dv.Capacity != 10 || dv.Count != 0)
throw new Exception("constructor setting capacity (2) test failed");
dv.Capacity = 20;
if (dv.Capacity != 20)
throw new Exception("capacity test (1) failed");
dv.Add(1.11);
try {
dv.Capacity = dv.Count-1;
throw new Exception("capacity test (2) failed");
} catch (ArgumentOutOfRangeException) {
}
// SetRange() test
for (int i=dv.Count; i<collectionSize; i++) {
dv.Add(0.0);
}
dv.SetRange(0, vect);
if (dv.Count != collectionSize)
throw new Exception("SetRange count check test failed");
for (int i=0; i<collectionSize; i++) {
if (vect[i] != dv[i])
throw new Exception("SetRange test (1) failed, index:" + i);
}
try {
dv.SetRange(-1, vect);
throw new Exception("SetRange test (2) failed");
} catch (ArgumentOutOfRangeException) {
}
try {
dv.SetRange(1, vect);
throw new Exception("SetRange test (3) failed");
} catch (ArgumentOutOfRangeException) {
}
try {
vect.SetRange(0, null);
throw new Exception("SetRange (4) test failed");
} catch (ArgumentNullException) {
}
// Reverse() test
dv.Reverse();
for (int i=0; i<collectionSize; i++) {
if (vect[i] != dv[collectionSize-i-1])
throw new Exception("Reverse test (1) failed, index:" + i);
}
dv.Reverse(0, collectionSize);
for (int i=0; i<collectionSize; i++) {
if (vect[i] != dv[i])
throw new Exception("Reverse test (2) failed, index:" + i);