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


C++ Dynamic::CreateIndex方法代码示例

本文整理汇总了C++中Dynamic::CreateIndex方法的典型用法代码示例。如果您正苦于以下问题:C++ Dynamic::CreateIndex方法的具体用法?C++ Dynamic::CreateIndex怎么用?C++ Dynamic::CreateIndex使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Dynamic的用法示例。


在下文中一共展示了Dynamic::CreateIndex方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: SetCases

  void SetCases()
  {
    std::string error;
    Dynamic table = TABLE;
    nkit::TableIndex::Ptr index;
    nkit::TableIndex::ConstIterator it;

    DynamicVector vargs;
    vargs.push_back(Dynamic("NEW"));
    vargs.push_back(Dynamic(0));
    vargs.push_back(Dynamic(true));
    vargs.push_back(Dynamic(0));
    vargs.push_back(Dynamic(0.0));

    COMMON_TABLE_INIT(table);

    index = table.CreateIndex("name,name1", &error);
    NKIT_TEST_ASSERT_WITH_TEXT(index, error);

    NKIT_TEST_ASSERT(table.SetRow(table.height() / 2, vargs));
    DynamicVector::iterator vit = vargs.begin();
    for (size_t col = 0; vit != vargs.end(); ++vit, ++col)
    {
  #if defined(MY_TRACE_)
    print(*vit, "", false);
    std::cout << " <> ";
    print(table.GetCellValue(table.height() / 2, col));
  #endif // MY_TRACE_
      NKIT_TEST_ASSERT(*vit == table.GetCellValue(table.height() / 2, col));
    } // for
    NKIT_TEST_ASSERT(index->GetEqual(Dynamic("NEW"),Dynamic(0)) != index->end());
  }
开发者ID:dedok,项目名称:nkit,代码行数:32,代码来源:test_dynamic_table.cpp

示例2: AppendCases

  void AppendCases()
  {
    std::string error;
    Dynamic table = TABLE;
    nkit::TableIndex::Ptr index;
    nkit::TableIndex::ConstIterator it;

    COMMON_TABLE_INIT(table);

    // Fail cases tests
    for (uint64_t ops = 0; ops < TABLE_GROW_SIZE; ++ops) // wrong type
       NKIT_TEST_ASSERT(table.AppendRow(Dynamic(ops), Dynamic(3), Dynamic(false), Dynamic(1)) ==
          false);

    NKIT_TEST_ASSERT(table == e);

    NKIT_TEST_ASSERT(!table.CreateIndex("", &error));
    NKIT_TEST_ASSERT(!table.CreateIndex("name,name1,name10", &error));

    index = table.CreateIndex("name,name1,name3", &error);
    NKIT_TEST_ASSERT(index);
    NKIT_TEST_ASSERT(index->GetEqual(Dynamic(3), Dynamic(1)) == index->end());
    NKIT_TEST_ASSERT(index->GetEqual(Dynamic("A3"), Dynamic(3)) == index->end());

    // Good cases test
    it = index->GetEqual(Dynamic("A3"), Dynamic(3), Dynamic(1));
    NKIT_TEST_ASSERT(it[4] == Dynamic(1.0));

    for (size_t ops = 0; ops < TABLE_GROW_SIZE; ++ops)
      NKIT_TEST_ASSERT(table.AppendRow(Dynamic("A3"), Dynamic(3),
          Dynamic(false), Dynamic(1), Dynamic(double(2.0 + ops))));

    it = index->GetEqual(Dynamic("A3"), Dynamic(3), Dynamic(1));
    NKIT_TEST_ASSERT(it != index->end());
    for (; it != index->end(); ++it)
    {
  #if defined(MY_TRACE_)
        print(it[4]);
  #endif // MY_TRACE_
    }
  }
开发者ID:dedok,项目名称:nkit,代码行数:41,代码来源:test_dynamic_table.cpp

示例3: DeleteCases

  void DeleteCases()
  {
    std::string error;
    Dynamic table = TABLE;
    nkit::TableIndex::Ptr index;
    nkit::TableIndex::ConstIterator it;

    COMMON_TABLE_INIT(table);

    index = table.CreateIndex("name,name1,name3", &error);

    // Fail cases tests
    NKIT_TEST_ASSERT(index);
    NKIT_TEST_ASSERT(index->GetEqual(Dynamic(3), Dynamic(1)) == index->end());
    NKIT_TEST_ASSERT(index->GetEqual(Dynamic("A3"), Dynamic(3)) == index->end());

    // Good cases tests
    for (size_t ops = 0; ops < TABLE_GROW_SIZE; ++ops)
    {
      DynamicVector vargs;
      vargs.push_back(Dynamic("A3"));
      vargs.push_back(Dynamic(3));
      vargs.push_back(Dynamic(false));
      vargs.push_back(Dynamic(1));
      vargs.push_back(Dynamic(double(2.0 + ops)));
      NKIT_TEST_ASSERT(table.InsertRow(0, vargs));
    }

    for (size_t ops = 0; ops < TABLE_GROW_SIZE; ++ops)
      NKIT_TEST_ASSERT(table.DeleteRow(0));

    it = index->GetEqual(Dynamic("A3"), Dynamic(3), Dynamic(1));
    NKIT_TEST_ASSERT(it != index->end());
    for (; it != index->end(); ++it)
    {
  #if defined(MY_TRACE_)
        print(it[4]);
  #endif // MY_TRACE_
    }

    NKIT_TEST_ASSERT(table == e);
  }
开发者ID:dedok,项目名称:nkit,代码行数:42,代码来源:test_dynamic_table.cpp

示例4: InsertCases

  void InsertCases()
  {
    std::string error;
    Dynamic table = TABLE;
    nkit::TableIndex::Ptr index;
    nkit::TableIndex::ConstIterator it;

    COMMON_TABLE_INIT(table);

    // Fail cases tests
    for (size_t ops = 0; ops < TABLE_GROW_SIZE; ++ops) // wrong type
    {
      DynamicVector vargs;
      vargs.push_back(Dynamic(1));
      vargs.push_back(Dynamic(3));
      vargs.push_back(Dynamic(false));
      vargs.push_back(Dynamic(1));
      vargs.push_back(Dynamic("name"));
      NKIT_TEST_ASSERT(table.InsertRow(0, vargs) == false);
    }
    NKIT_TEST_ASSERT(table == e);

    index = table.CreateIndex("name,name1,name3", &error);
    NKIT_TEST_ASSERT(index);
    NKIT_TEST_ASSERT(index->GetEqual(Dynamic(3), Dynamic(1)) == index->end());
    NKIT_TEST_ASSERT(index->GetEqual(Dynamic("A3"), Dynamic(3)) == index->end());

    // Good cases tests
    for (size_t ops = 0; ops < TABLE_GROW_SIZE; ++ops)
    {
      DynamicVector vargs;
      vargs.push_back(Dynamic("A3"));
      vargs.push_back(Dynamic(3));
      vargs.push_back(Dynamic(false));
      vargs.push_back(Dynamic(1));
      vargs.push_back(Dynamic(double(2.0 + ops)));
      NKIT_TEST_ASSERT(table.InsertRow(0, vargs));
    }
    it = index->GetEqual(Dynamic("A3"), Dynamic(3), Dynamic(1));
    NKIT_TEST_ASSERT(it != index->end());
    for (; it != index->end(); ++it)
    {
  #if defined(MY_TRACE_)
        print(it[4]);
  #endif // MY_TRACE_
    }

    for (size_t ops = 0; ops < TABLE_GROW_SIZE; ++ops)
    {
      DynamicVector vargs;
      vargs.push_back(Dynamic("A10"));
      vargs.push_back(Dynamic(3));
      vargs.push_back(Dynamic(false));
      vargs.push_back(Dynamic(1));
      vargs.push_back(Dynamic(double(1.0 + ops)));
      NKIT_TEST_ASSERT(table.InsertRow(table.height() / 2, vargs));
    }

    it = index->GetEqual(Dynamic("A10"), Dynamic(3), Dynamic(1));
    NKIT_TEST_ASSERT(it != index->end());
    for (; it != index->end(); ++it)
    {
  #if defined(MY_TRACE_)
        print(it[4]);
  #endif // MY_TRACE_
    }

    it = index->GetEqual(Dynamic("A"), Dynamic(1), Dynamic(1));
    NKIT_TEST_ASSERT(it != index->end());
    NKIT_TEST_ASSERT(it[4] == Dynamic(99.0));

    it = index->GetEqual(Dynamic("A2"), Dynamic(2), Dynamic::GetDefault(detail::INTEGER));
    NKIT_TEST_ASSERT(it != index->end());

    it = index->GetEqual(Dynamic("A1"), Dynamic(1), Dynamic::GetDefault(detail::INTEGER));
    NKIT_TEST_ASSERT(it != index->end());
  }
开发者ID:dedok,项目名称:nkit,代码行数:77,代码来源:test_dynamic_table.cpp


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