100 万または 10 億の STL ベクトルを並べ替えて連結し、単一の STL ベクトルにする最良の方法は何ですか。現在、私が行っている方法は、ベクトルを反復処理して各操作を実行することです。
ここに疑似コードがあります
typedef unsigned long long int ULLInt;
ULLInt N = 1000000;
vector<vector<ULLInt> > vecVec( N, vector<ULLInt>() );
vector<ULLInt> concatVec;
// ...
// ... fill vectors inside vecVec here
// .. we also get here the total number of values inserted in all vectors (count)
// ...
// reserve the space
concatVec.reserve( count);
// sort each vector and concatenate them in sequence
for( ULLInt i=0; i<N; i++)
sort( vecVec[i].begin(), vecVec[i].end() );
concatVec.insert( concatVec.end(), vecVec[i].begin(), vecVec[i].end() );
end for
concatVec をソートする必要はないことに注意してください。提案をありがとう。