迭代一个大的std :: vector

时间:2017-08-15 08:13:09

标签: c++11 vector iteration

我有一个元组的C ++向量。元组由三个双精度和一个整数组成。矢量可能包含数十万个元素。即使使用C ++ 11 for(auto element:vector){}循环,我设法迭代不超过大约100k个元素。是否有任何其他解决方案来迭代整个“大”向量(目前275k元素)? 我的代码:

    for(auto record : rD)
    {
//      Find indices:
        indxSc  = std::get<2>(record) - 1;
        indxSp  = static_cast<int>( std::get<0>(record)/0.3 );
        if(indxSp > 47 )indxSp = 46;
        indxDir = findSector72( std::get<1>(record) );

//      Increment counts in bins
        ++cntSit[indxSc][indxSp][indxDir];
        ++cntSpeed[indxSp];

//      Add reciprocal of wind speed to sum for <1/u>
        valSpeed[indxSp] = valSpeed[indxSp] + 1./( std::get<0>(record) );
    }

0 个答案:

没有答案