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