BIE |
/home/weinberg/src/BIE/include/hash_map_unordered_map.h00001 // This is really -*- C++ -*- 00002 00003 #ifndef hash_map_unordered_map_h 00004 #define hash_map_unordered_map_h 00005 00006 #include <tr1/unordered_map> 00007 #include <boost/version.hpp> 00008 #include <boost/archive/text_oarchive.hpp> 00009 #include <boost/archive/text_iarchive.hpp> 00010 #include <boost/serialization/utility.hpp> 00011 #include <boost/serialization/collections_save_imp.hpp> 00012 #include <boost/serialization/collections_load_imp.hpp> 00013 #include <boost/serialization/split_free.hpp> 00014 #if ((BOOST_VERSION / 100) % 1000) >= 42 00015 #include <boost/serialization/hash_map.hpp> 00016 #endif 00017 00018 namespace boost { 00019 namespace serialization { 00020 template<class Archive, class Type, class Key, class Hash, class 00021 Compare, class Allocator > 00022 inline void save( 00023 Archive & ar, 00024 const std::tr1::unordered_map<Key, Type, Hash, Compare, Allocator> &t, 00025 const unsigned int /* file_version */ 00026 ){ 00027 boost::serialization::stl::save_collection< 00028 Archive, 00029 std::tr1::unordered_map<Key, Type, Hash, Compare, Allocator> 00030 >(ar, t); 00031 } 00032 00033 template<class Archive, class Type, class Key, class Hash, class 00034 Compare, class Allocator > 00035 inline void load( 00036 Archive & ar, 00037 std::tr1::unordered_map<Key, Type, Hash, Compare, Allocator> &t, 00038 const unsigned int /* file_version */ 00039 ){ 00040 boost::serialization::stl::load_collection< 00041 Archive, 00042 std::tr1::unordered_map<Key, Type, Hash, Compare, Allocator>, 00043 #if ((BOOST_VERSION / 100) % 1000) == 35 00044 boost::serialization::stl::archive_input_unique< 00045 #else 00046 boost::serialization::stl::archive_input_map< 00047 #endif 00048 Archive, std::tr1::unordered_map<Key, Type, Hash, Compare, 00049 Allocator> >, 00050 00051 boost::serialization::stl::no_reserve_imp<std::tr1::unordered_map< 00052 Key, Type, Hash, Compare, Allocator 00053 > 00054 > 00055 >(ar, t); 00056 } 00057 00060 template<class Archive, class Type, class Key, class Hash, class 00061 Compare, class Allocator > 00062 inline void serialize( 00063 Archive & ar, 00064 std::tr1::unordered_map<Key, Type, Hash, Compare, Allocator> &t, 00065 const unsigned int file_version 00066 ){ 00067 boost::serialization::split_free(ar, t, file_version); 00068 } 00069 00071 template<class Archive, class Type, class Key, class Hash, class 00072 Compare, class Allocator > 00073 inline void save( 00074 Archive & ar, 00075 const std::tr1::unordered_multimap<Key, Type, Hash, Compare, 00076 Allocator> &t, 00077 const unsigned int /* file_version */ 00078 ){ 00079 boost::serialization::stl::save_collection< 00080 Archive, 00081 std::tr1::unordered_multimap<Key, Type, Hash, Compare, Allocator> 00082 >(ar, t); 00083 } 00084 00085 template<class Archive, class Type, class Key, class Hash, class 00086 Compare, class Allocator > 00087 inline void load( 00088 Archive & ar, 00089 std::tr1::unordered_multimap<Key, Type, Hash, Compare, Allocator> &t, 00090 const unsigned int /* file_version */ 00091 ){ 00092 boost::serialization::stl::load_collection< 00093 Archive, 00094 std::tr1::unordered_multimap<Key, Type, Hash, Compare, Allocator>, 00095 #if ((BOOST_VERSION / 100) % 1000) == 35 00096 boost::serialization::stl::archive_input_multi< 00097 #elif ((BOOST_VERSION / 100) % 1000) <=40 00098 boost::serialization::stl::archive_input_multimap< 00099 #else 00100 boost::serialization::stl::archive_input_hash_multimap< 00101 #endif 00102 Archive, std::tr1::unordered_multimap<Key, Type, Hash, 00103 Compare, Allocator> 00104 >, 00105 boost::serialization::stl::no_reserve_imp< 00106 std::tr1::unordered_multimap<Key, Type, Hash, Compare, 00107 Allocator> 00108 > 00109 >(ar, t); 00110 } 00111 00112 // split non-intrusive serialization function member into separate 00113 // non intrusive save/load member functions 00114 template<class Archive, class Type, class Key, class Hash, class 00115 Compare, class Allocator > 00116 inline void serialize( 00117 Archive & ar, 00118 std::tr1::unordered_multimap<Key, Type, Hash, Compare, Allocator> &t, 00119 const unsigned int file_version 00120 ){ 00121 boost::serialization::split_free(ar, t, file_version); 00122 } 00123 } // serialization 00124 } // namespace boost 00125 00126 00127 #define HASHMAP_NAMESPACE_BEGIN namespace std { namespace tr1 { 00128 #define HASHMAP_NAMESPACE_END } } 00129 00130 HASHMAP_NAMESPACE_BEGIN 00157 00158 template<> 00159 struct hash<std::string const> { 00161 size_t operator()(const std::string& x) const { 00162 return hash<const char*>()( x.c_str() ); 00163 } 00164 }; 00165 HASHMAP_NAMESPACE_END 00166 00167 using std::tr1::hash; 00168 00169 namespace bie { 00171 template<class _Key, class _Tp, 00172 class _Hash = hash<_Key>, 00173 class _Pred = std::equal_to<_Key>, 00174 class _Alloc = std::allocator<std::pair<const _Key, _Tp> > > 00175 struct hashers 00176 { 00178 typedef std::tr1::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc> 00179 MapType; 00181 typedef std::tr1::unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc> 00182 MultiMapType; 00183 }; 00184 } 00185 00186 #endif Send suggestions, questions, and feedback to WEINBERG at ASTRO dot UMASS dot EDU. Documentation generated at Fri Mar 26 00:35:10 2010 by
|