PhoenixPresentation  2.0.0
Set of cmake function to automate presentation generation
phoenix_vector_split.h File Reference
#include <string>
#include <vector>
+ Include dependency graph for phoenix_vector_split.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

template<typename T >
void phoenix_vector_split (std::vector< std::vector< T > > &vecVecOutput, const std::vector< T > &vecInput, size_t nbPart)
 Split a list in a list of lists, keep the order of the input file if the output is used for std::thread. More...
 

Function Documentation

◆ phoenix_vector_split()

template<typename T >
void phoenix_vector_split ( std::vector< std::vector< T > > &  vecVecOutput,
const std::vector< T > &  vecInput,
size_t  nbPart 
)

Split a list in a list of lists, keep the order of the input file if the output is used for std::thread.

Parameters
[out]vecVecOutput: output list of list of nbPart parts
vecInput: input list to be split
nbPart: number of part in which to split the vecInput

Definition at line 19 of file phoenix_vector_split.h.

19  {
20  if(vecInput.size() == 0lu) return;
21  size_t i(0lu);
22  for(typename std::vector<T>::const_iterator it(vecInput.begin()); it != vecInput.end(); ++it){
23  if(vecVecOutput.size() <= i){
24  std::vector<T> vecTmp;
25  vecTmp.push_back(*it);
26  vecVecOutput.push_back(vecTmp);
27  }else{
28  vecVecOutput[i].push_back(*it);
29  }
30  ++i;
31  if(i >= nbPart){i = 0lu;}
32  }
33 }

Referenced by testVectorSplit(), and testVectorSplit2().

+ Here is the caller graph for this function: