]> Creatis software - clitk.git/blob - common/clitkListOfPair.txx
Initial revision
[clitk.git] / common / clitkListOfPair.txx
1 #ifndef CLITKLISTOFPAIR_TXX
2 #define CLITKLISTOFPAIR_TXX
3
4 /**
5  =================================================
6  * @file   clitkListOfPair.txx
7  * @author David Sarrut <david.sarrut@creatis.insa-lyon.fr>
8  * @date   27 Feb 2007 09:44:48
9  * 
10  * @brief  
11  * 
12  * 
13  =================================================*/
14
15 //====================================================================
16 template<class MapType>
17 void ReadMap(const std::string & filename, MapType & list, bool inverse) {
18   std::ifstream is;
19   clitk::openFileForReading(is, filename);
20   clitk::skipComment(is);
21   typedef typename MapType::key_type KType;
22   KType v1;
23   typedef typename MapType::mapped_type MType;
24   MType v2;
25   while (is) {
26         is >> v1;
27         is >> v2;
28         if (is) {
29           if (!inverse) list.insert(std::pair<KType, MType>(v1,v2));
30           else list.insert(std::pair<KType, MType>(v2,v1));       
31         }
32         clitk::skipComment(is);
33   }
34   is.close();
35 }
36 //====================================================================
37
38 #endif /* end #define CLITKLISTOFPAIR_TXX */
39