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


C++ DataVector::at方法代码示例

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


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

示例1: main

int main(int argc, char *argv[])
{
  struct shm_remove
  {
     shm_remove() { boost::interprocess::shared_memory_object::remove("MySharedMemory"); }
     ~shm_remove(){ boost::interprocess::shared_memory_object::remove("MySharedMemory"); }
  } remover;
  boost::interprocess::managed_shared_memory segment(boost::interprocess::create_only, "MySharedMemory", 65536);
  const ShmemAllocator alloc_inst (segment.get_segment_manager());
  DataVector *myvector = segment.construct<DataVector>("MyVector")(alloc_inst);
  for(int i = 0; i < 6; ++i) { //Insert data in the vector
    printf("%d ", i);
     myvector->push_back(i*3);
  }
  while(1)
  {
      for(int i = 0; i < 6; ++i) { //Insert data in the vector
        printf("%d ", i);
         myvector->at(i) = rand()*rand();
         printf("%f ", myvector->at(i));
      }
      printf("\n");
  }
return 0;
};
开发者ID:Daiver,项目名称:scripts,代码行数:25,代码来源:send.cpp

示例2: test_datavector

/**
 * Test DataVector
 */
void test_datavector()
{

    DataVector src;
    src.push_back(DataPoint(1,true));
    src.push_back(DataPoint(2,true));
    src.push_back(DataPoint(3,true));

    std::vector<bool> mask(3,true);
    DataVector dst;
    
    dst.copy(src,mask);
    ASSERT_EQUAL(dst.at(0).value, 1, "DataVector::copy value failed on enabled data point at 0");
    ASSERT(dst.at(0).active, "DataVector::copy active failed on enabled data point at 0");
    ASSERT_EQUAL(dst.at(1).value, 2, "DataVector::copy value failed on enabled data point at 1");
    ASSERT(dst.at(1).active, "DataVector::copy active failed on enabled data point at 1");
    ASSERT_EQUAL(dst.at(2).value, 3, "DataVector::copy value failed on enabled data point at 2");
    ASSERT(dst.at(2).active, "DataVector::copy active failed on enabled data point at 2");

    src.deactivate();
    dst.clear();
    dst.copy(src,mask);
    ASSERT_EXCEPTION(dst.at(0), "DataVector::copy failed on disabled data point at 0");
    ASSERT_EXCEPTION(dst.at(1), "DataVector::copy failed on disabled data point at 1");
    ASSERT_EXCEPTION(dst.at(2), "DataVector::copy failed on disabled data point at 2");

}
开发者ID:dpmcmlxxvi,项目名称:clistats,代码行数:30,代码来源:clistatstest.cpp

示例3: main

int main(int argc, char *argv[])
{
      boost::interprocess::managed_shared_memory segment(boost::interprocess::open_only, "MySharedMemory");
      DataVector *myvector = segment.find<DataVector>("MyVector").first;
      for(int i = 0; i < 100; ++i)  //Insert data in the vector
      {
        printf("%f ", (float)myvector->at(i));
      }
   return 0;
};
开发者ID:Daiver,项目名称:scripts,代码行数:10,代码来源:recv.cpp


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