ESPResSo
Extensible Simulation Package for Research on Soft Matter Systems
Loading...
Searching...
No Matches
unordered_map.hpp
Go to the documentation of this file.
1/*
2 * Copyright (C) 2010-2022 The ESPResSo project
3 *
4 * This file is part of ESPResSo.
5 *
6 * ESPResSo is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * ESPResSo is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20#pragma once
21
22#include <boost/serialization/split_free.hpp>
23#include <boost/serialization/utility.hpp>
24
25#include <unordered_map>
26
27namespace boost::serialization {
28
29template <typename Archive, typename K, typename V>
30void load(Archive &ar, std::unordered_map<K, V> &map, unsigned const int) {
31 using value_type = typename std::unordered_map<K, V>::value_type;
32 using size_type = typename std::unordered_map<K, V>::size_type;
33
34 size_type count;
35 ar >> count;
36 map.reserve(count);
37
38 value_type pair{};
39 for (size_type i = 0; i < count; i++) {
40 ar >> pair;
41 map.emplace_hint(map.end(), pair);
42 }
43}
44
45template <typename Archive, typename K, typename V>
46void save(Archive &ar, std::unordered_map<K, V> const &map,
47 unsigned const int) {
48 auto const count = map.size();
49 ar << count;
50
51 for (auto const &pair : map) {
52 ar << pair;
53 }
54}
55
56template <typename Archive, typename K, typename V>
57void serialize(Archive &ar, std::unordered_map<K, V> &map,
58 unsigned int const version) {
59 split_free(ar, map, version);
60}
61
62} // namespace boost::serialization
void serialize(Archive &ar, std::tuple< T... > &pack, unsigned int const)
Serialize std::tuple.
void load(Archive &ar, GpuParticleData::GpuParticle &p, unsigned const)
void save(Archive &ar, GpuParticleData::GpuParticle const &p, unsigned const)