| Directory: | ./ |
|---|---|
| File: | tmp_project/PhoenixString/src/phoenix_vector_split.h |
| Date: | 2024-12-09 15:28:54 |
| Exec | Total | Coverage | |
|---|---|---|---|
| Lines: | 12 | 12 | 100.0% |
| Branches: | 10 | 11 | 90.9% |
| Line | Branch | Exec | Source |
|---|---|---|---|
| 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 | |||
| 13 | ///Split a list in a list of lists, keep the order of the input file if the output is used for std::thread | ||
| 14 | /** @param[out] vecVecOutput : output list of list of nbPart parts | ||
| 15 | * @param vecInput : input list to be split | ||
| 16 | * @param nbPart : number of part in which to split the vecInput | ||
| 17 | */ | ||
| 18 | template <typename T> | ||
| 19 | 2 | void phoenix_vector_split(std::vector<std::vector<T> > & vecVecOutput, const std::vector<T> & vecInput, size_t nbPart){ | |
| 20 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
|
2 | if(vecInput.size() == 0lu) return; |
| 21 | 2 | size_t i(0lu); | |
| 22 |
2/2✓ Branch 4 taken 12 times.
✓ Branch 5 taken 2 times.
|
14 | for(typename std::vector<T>::const_iterator it(vecInput.begin()); it != vecInput.end(); ++it){ |
| 23 |
2/2✓ Branch 1 taken 4 times.
✓ Branch 2 taken 8 times.
|
12 | if(vecVecOutput.size() <= i){ |
| 24 | 4 | std::vector<T> vecTmp; | |
| 25 |
1/1✓ Branch 2 taken 4 times.
|
4 | vecTmp.push_back(*it); |
| 26 |
1/1✓ Branch 1 taken 4 times.
|
4 | vecVecOutput.push_back(vecTmp); |
| 27 | 4 | }else{ | |
| 28 |
1/1✓ Branch 3 taken 8 times.
|
8 | vecVecOutput[i].push_back(*it); |
| 29 | } | ||
| 30 | 12 | ++i; | |
| 31 |
2/2✓ Branch 0 taken 5 times.
✓ Branch 1 taken 7 times.
|
12 | if(i >= nbPart){i = 0lu;} |
| 32 | } | ||
| 33 | } | ||
| 34 | |||
| 35 | #endif | ||
| 36 | |||
| 37 |