1941f7c22654da86c592953f2be5451361b5a0cb
[h316.git] / pc-tools / ldc2 / src / tool.hh
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);
10 extern int dump_vector_fp(vector<string> strings, FILE * fp);
11
12
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 }
31
32 #endif