MC_helper_stl.hpp

Go to the documentation of this file.
00001 /*
00002 **    Mesh Converter
00003 **    Copyright (C) 2009 Damien Rohmer
00004 **
00005 **    This program is free software: you can redistribute it and/or modify
00006 **    it under the terms of the GNU General Public License as published by
00007 **    the Free Software Foundation, either version 3 of the License, or
00008 **    (at your option) any later version.
00009 **
00010 **   This program is distributed in the hope that it will be useful,
00011 **    but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 **    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013 **    GNU General Public License for more details.
00014 **
00015 **    You should have received a copy of the GNU General Public License
00016 **    along with this program.  If not, see <http://www.gnu.org/licenses/>.
00017 */
00018 
00019 #ifndef _MC_HELPER_STL_HPP_
00020 #define _MC_HELPER_STL_HPP_
00021 
00022 #include <iostream>
00023 #include <vector>
00024 #include <map>
00025 
00026 namespace mesh_conv
00027 {
00029     class MC_helper_stl
00030     {
00031     public:
00032 
00034         template <class TA,class TB>
00035                 static std::vector<TB> map_arg2_to_vector(const std::map<TA,TB>& m)
00036         {
00037             typename std::map<TA,TB>::const_iterator it=m.begin();
00038             typename std::map<TA,TB>::const_iterator it_end=m.end();
00039 
00040             std::vector <TB> vec;
00041             for(;it!=it_end;++it)
00042                 vec.push_back(it->second);
00043             return vec;
00044         }
00045 
00047         template <class TA,class TB>
00048                 static std::map<TB,TA> reverse_map(const std::map<TA,TB>& m)
00049         {
00050             std::map <TB,TA> reversed;
00051             typename std::map <TA,TB> :: const_iterator it=m.begin();
00052             typename std::map <TA,TB> :: const_iterator it_end=m.end();
00053             for(;it!=it_end;++it)
00054                 reversed.insert(std::make_pair(it->second,it->first));
00055             return reversed;
00056         }
00057 
00058     private:
00059     };
00060 }
00061 
00062 #endif

Generated on Sun Apr 18 20:24:47 2010 by  doxygen 1.6.1