Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031 #ifndef SUNDANCE_MAP_H
00032 #define SUNDANCE_MAP_H
00033
00034 #include "SundanceDefs.hpp"
00035 #include <map>
00036
00037 #ifndef DOXYGEN_DEVELOPER_ONLY
00038
00039 namespace Sundance
00040 {
00041 using namespace Teuchos;
00042
00043
00044
00045
00046
00047 template<class Key, class Value, class Compare = std::less<Key> >
00048 class Map : public std::map<Key, Value, Compare>
00049 {
00050 public:
00051
00052 Map() : std::map<Key,Value,Compare>() {;}
00053
00054
00055 inline bool containsKey(const Key& key) const {return this->find(key) != this->end();}
00056
00057
00058 inline void put(const Key& key, const Value& value)
00059 {this->operator[](key) = value;}
00060
00061
00062 inline const Value& get(const Key& key) const
00063 {return (*(this->find)(key)).second;}
00064
00065
00066 inline Value& get(const Key& key)
00067 {return (*(this->find)(key)).second;}
00068 };
00069
00070 }
00071
00072 namespace std
00073 {
00074
00075
00076
00077 template<class Key, class Value, class Compare> inline
00078 std::ostream& operator<<(std::ostream& os, const Sundance::Map<Key, Value, Compare>& m)
00079 {
00080 typename Sundance::Map<Key, Value, Compare>::const_iterator iter;
00081
00082 os << "Map[";
00083 int k = 0 ;
00084 for (iter=m.begin(); iter != m.end(); iter++, k++)
00085 {
00086 os << "{" << (*iter).first << ", " << (*iter).second << "}";
00087 if (k < (int) m.size()-1) os << ", ";
00088 }
00089 os << "]";
00090 return os;
00091 }
00092 }
00093
00094 #endif
00095 #endif