当前位置: 首页>>代码示例>>C#>>正文


C# DoubleVector.RemoveAt方法代码示例

本文整理汇总了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);
开发者ID:Reticulatas,项目名称:MochaEngineFinal,代码行数:67,代码来源:li_std_vector_runme.cs


注:本文中的DoubleVector.RemoveAt方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。