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