| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
#pragma once |
| 32 |
|
| 33 |
#include <boost/serialization/split_free.hpp> |
| 34 |
#include <unordered_map> |
| 35 |
#include <unordered_set> |
| 36 |
|
| 37 |
namespace boost |
| 38 |
{ |
| 39 |
namespace serialization |
| 40 |
{ |
| 41 |
template <class Archive, class h_key, class hval> |
| 42 |
inline void save(Archive &a, const std::unordered_map<h_key, hval> &x, const boost::serialization::version_type ver) |
| 43 |
{ |
| 44 |
size_t s = x.size(); |
| 45 |
a << s; |
| 46 |
for(auto& v: x) |
| 47 |
{ |
| 48 |
a << v.first; |
| 49 |
a << v.second; |
| 50 |
} |
| 51 |
} |
| 52 |
|
| 53 |
template <class Archive, class h_key, class hval> |
| 54 |
inline void load(Archive &a, std::unordered_map<h_key, hval> &x, const boost::serialization::version_type ver) |
| 55 |
{ |
| 56 |
x.clear(); |
| 57 |
size_t s = 0; |
| 58 |
a >> s; |
| 59 |
for(size_t i = 0; i != s; i++) |
| 60 |
{ |
| 61 |
h_key k; |
| 62 |
hval v; |
| 63 |
a >> k; |
| 64 |
a >> v; |
| 65 |
x.insert(std::pair<h_key, hval>(k, v)); |
| 66 |
} |
| 67 |
} |
| 68 |
|
| 69 |
|
| 70 |
template <class Archive, class h_key, class hval> |
| 71 |
inline void save(Archive &a, const std::unordered_multimap<h_key, hval> &x, const boost::serialization::version_type ver) |
| 72 |
{ |
| 73 |
size_t s = x.size(); |
| 74 |
a << s; |
| 75 |
for(auto& v: x) |
| 76 |
{ |
| 77 |
a << v.first; |
| 78 |
a << v.second; |
| 79 |
} |
| 80 |
} |
| 81 |
|
| 82 |
template <class Archive, class h_key, class hval> |
| 83 |
inline void load(Archive &a, std::unordered_multimap<h_key, hval> &x, const boost::serialization::version_type ver) |
| 84 |
{ |
| 85 |
x.clear(); |
| 86 |
size_t s = 0; |
| 87 |
a >> s; |
| 88 |
for(size_t i = 0; i != s; i++) |
| 89 |
{ |
| 90 |
h_key k; |
| 91 |
hval v; |
| 92 |
a >> k; |
| 93 |
a >> v; |
| 94 |
x.emplace(k, v); |
| 95 |
} |
| 96 |
} |
| 97 |
|
| 98 |
|
| 99 |
template <class Archive, class hval> |
| 100 |
inline void save(Archive &a, const std::unordered_set<hval> &x, const boost::serialization::version_type ver) |
| 101 |
{ |
| 102 |
size_t s = x.size(); |
| 103 |
a << s; |
| 104 |
for(auto& v: x) |
| 105 |
{ |
| 106 |
a << v; |
| 107 |
} |
| 108 |
} |
| 109 |
|
| 110 |
template <class Archive, class hval> |
| 111 |
inline void load(Archive &a, std::unordered_set<hval> &x, const boost::serialization::version_type ver) |
| 112 |
{ |
| 113 |
x.clear(); |
| 114 |
size_t s = 0; |
| 115 |
a >> s; |
| 116 |
for(size_t i = 0; i != s; i++) |
| 117 |
{ |
| 118 |
hval v; |
| 119 |
a >> v; |
| 120 |
x.insert(v); |
| 121 |
} |
| 122 |
} |
| 123 |
|
| 124 |
|
| 125 |
template <class Archive, class h_key, class hval> |
| 126 |
inline void serialize(Archive &a, std::unordered_map<h_key, hval> &x, const boost::serialization::version_type ver) |
| 127 |
{ |
| 128 |
split_free(a, x, ver); |
| 129 |
} |
| 130 |
|
| 131 |
template <class Archive, class h_key, class hval> |
| 132 |
inline void serialize(Archive &a, std::unordered_multimap<h_key, hval> &x, const boost::serialization::version_type ver) |
| 133 |
{ |
| 134 |
split_free(a, x, ver); |
| 135 |
} |
| 136 |
|
| 137 |
template <class Archive, class hval> |
| 138 |
inline void serialize(Archive &a, std::unordered_set<hval> &x, const boost::serialization::version_type ver) |
| 139 |
{ |
| 140 |
split_free(a, x, ver); |
| 141 |
} |
| 142 |
} |
| 143 |
} |