unordered_map.h
Go to the documentation of this file.
00001 /* 00002 * Copyright 2006-2009 Savarese Software Research Corporation 00003 * 00004 * Licensed under the Apache License, Version 2.0 (the "License"); 00005 * you may not use this file except in compliance with the License. 00006 * You may obtain a copy of the License at 00007 * 00008 * https://www.savarese.com/software/ApacheLicense-2.0 00009 * 00010 * Unless required by applicable law or agreed to in writing, software 00011 * distributed under the License is distributed on an "AS IS" BASIS, 00012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00013 * See the License for the specific language governing permissions and 00014 * limitations under the License. 00015 */ 00016 00022 #ifndef __SSRC_WSPR_UTILITY_UNORDERED_MAP_H 00023 #define __SSRC_WSPR_UTILITY_UNORDERED_MAP_H 00024 00025 // This is a horrible kluge to work around boost serialization not 00026 // supporting <unordered_map>. As soon as boost serialization supports 00027 // unordered_map, get rid of all of the hacks. 00028 00029 #include <unordered_map> 00030 #include <boost/serialization/serialization.hpp> 00031 00032 #define hash_map unordered_map 00033 #define hash_multimap unordered_multimap 00034 00035 #ifdef BOOST_HASH_MAP_HEADER 00036 #undef BOOST_HASH_MAP_HEADER 00037 #endif 00038 #ifdef BOOST_STD_EXTENSION_NAMESPACE 00039 #undef BOOST_STD_EXTENSION_NAMESPACE 00040 #endif 00041 #ifdef BOOST_SERIALIZATION_HASH_COLLECTIONS_LOAD_IMP_HPP 00042 #undef BOOST_SERIALIZATION_HASH_COLLECTIONS_LOAD_IMP_HPP 00043 #endif 00044 00045 #define BOOST_HASH_MAP_HEADER <unordered_map> 00046 #define BOOST_STD_EXTENSION_NAMESPACE std 00047 #define BOOST_SERIALIZATION_HASH_COLLECTIONS_LOAD_IMP_HPP 00048 #include <boost/serialization/nvp.hpp> 00049 #include <boost/serialization/collections_load_imp.hpp> 00050 00051 namespace boost{ 00052 namespace serialization { 00053 namespace stl { 00054 template<class Archive, class Container, class InputFunction> 00055 inline void load_hash_collection(Archive & ar, Container &s) 00056 { 00057 s.clear(); 00058 // retrieve number of elements 00059 collection_size_type count; 00060 collection_size_type bucket_count; 00061 boost::serialization::item_version_type item_version(0); 00062 ar >> BOOST_SERIALIZATION_NVP(count); 00063 if(3 < ar.get_library_version()){ 00064 ar >> BOOST_SERIALIZATION_NVP(bucket_count) 00065 >> BOOST_SERIALIZATION_NVP(item_version); 00066 } 00067 00068 s.rehash(bucket_count); 00069 00070 InputFunction ifunc; 00071 while(count-- > 0){ 00072 ifunc(ar, s, item_version); 00073 } 00074 } 00075 } 00076 } 00077 } 00078 00079 #include <boost/serialization/hash_map.hpp> 00080 #undef hash_map 00081 #undef hash_multimap 00082 00083 #endif
Copyright © 2006-2011 Savarese Software Research Corporation. All rights reserved.