ea4c19a4 |
1 | #ifndef TOOL_HH |
2 | #define TOOL_HH |
3 | |
4 | #include <vector> |
5 | #include <string> |
6 | |
7 | using namespace std; |
8 | |
9 | extern int dump_vector(vector<string> strings); |
874a2bd8 |
10 | extern int dump_vector_fp(vector<string> strings, FILE * fp); |
11 | |
874a2bd8 |
12 | |
de6b6757 |
13 | /*! |
14 | *\brief add contents of one vector to another vector uniquely. |
15 | *\param target Reference to the target vector. |
16 | *\param source Reference to the vector whose contents are to be added |
17 | * to target. |
18 | */ |
19 | template<typename T> |
20 | void merge_vector_unique(vector<T> &target, const vector<T> & source){ |
21 | for (unsigned int isource=0; isource<source.size();isource++){ |
22 | bool already_present=false; |
23 | for (unsigned int itarget=0;itarget<target.size();itarget++) |
24 | if (target[itarget]==source[isource]){ |
25 | already_present=true; |
26 | break; |
27 | } |
28 | if (!already_present) target.insert(target.end(),source[isource]); |
29 | } |
30 | } |
ea4c19a4 |
31 | |
32 | #endif |