1f5008b281d224ef201a077cb5e111ff4f3f1604
[h316.git] / pc-tools / ldc2 / src / tool.hh
1 /******************************************************************************
2 *
3 * LDC2 source code
4 *
5 * $Date: 2007/05/30 02:51:16 $
6 * $Author: hachti $
7 *
8 * $Log: tool.hh,v $
9 * Revision 2.1 2007/05/30 02:51:16 hachti
10 * Changed everything towards LDC2 use.
11 * Worked on the buildlib.sh.
12 * Centralized buildlib.sh to a new lib/common directory.
13 *
14 * Revision 2.0 2007-03-26 01:00:40 hachti
15 * *** empty log message ***
16 *
17 *
18 ******************************************************************************/
19
20 #ifndef TOOL_HH
21 #define TOOL_HH
22
23 #include <vector>
24 #include <string>
25
26 using namespace std;
27
28 extern int dump_vector(vector<string> strings);
29 extern int dump_vector_fp(vector<string> strings, FILE * fp);
30
31
32 /*!
33 *\brief add contents of one vector to another vector uniquely.
34 *\param target Reference to the target vector.
35 *\param source Reference to the vector whose contents are to be added
36 * to target.
37 */
38 template<typename T>
39 void merge_vector_unique(vector<T> &target, const vector<T> & source){
40 for (unsigned int isource=0; isource<source.size();isource++){
41 bool already_present=false;
42 for (unsigned int itarget=0;itarget<target.size();itarget++)
43 if (target[itarget]==source[isource]){
44 already_present=true;
45 break;
46 }
47 if (!already_present) target.insert(target.begin(),source[isource]);
48 }
49 }
50
51 #endif