PhoenixPresentation  2.0.0
Set of cmake function to automate presentation generation
phoenix_vector_split.h
Go to the documentation of this file.
1 /***************************************
2  Auteur : Pierre Aubert
3  Mail : pierre.aubert@lapp.in2p3.fr
4  Licence : CeCILL-C
5 ****************************************/
6 
7 #ifndef __PHOENIX_VECTOR_SPLIT_H__
8 #define __PHOENIX_VECTOR_SPLIT_H__
9 
10 #include <string>
11 #include <vector>
12 
14 
18 template <typename T>
19 void phoenix_vector_split(std::vector<std::vector<T> > & vecVecOutput, const std::vector<T> & vecInput, size_t nbPart){
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 }
34 
35 #endif
36 
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::thre...