本文整理汇总了C#中DoubleVector.RemoveAt方法的典型用法代码示例。如果您正苦于以下问题:C# DoubleVector.RemoveAt方法的具体用法?C# DoubleVector.RemoveAt怎么用?C# DoubleVector.RemoveAt使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DoubleVector
的用法示例。
在下文中一共展示了DoubleVector.RemoveAt方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
//.........这里部分代码省略.........
} catch (ArgumentOutOfRangeException) {
}
if (vect.Count != count)
throw new Exception("Insert after end (2) test failed");
pos = -1;
try {
vect.Insert(pos, 333.1); // should throw
throw new Exception("Insert before start (1) test failed");
} catch (ArgumentOutOfRangeException) {
}
if (vect.Count != count)
throw new Exception("Insert before start (2) test failed");
// Remove() test
vect.Remove(195.1);
count--;
vect.Remove(-5.1);
count--;
vect.Remove(85.1);
count--;
vect.Remove(9999.1); // element does not exist, should quietly do nothing
if (vect.Count != count)
throw new Exception("Remove count check test failed");
for (int i=0; i<collectionSize; i++) {
if (vect[i] != i*10.1)
throw new Exception("Remove test failed, index:" + i);
}
// RemoveAt() test
vect.Insert(0, -4.1);
vect.Insert(midCollection, 84.1);
vect.Insert(vect.Count, 194.1);
vect.RemoveAt(vect.Count-1);
vect.RemoveAt(midCollection);
vect.RemoveAt(0);
try {
vect.RemoveAt(-1);
throw new Exception("RemoveAt test (1) failed");
} catch (ArgumentOutOfRangeException) {
}
try {
vect.RemoveAt(vect.Count);
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);