unordered_multimap.hpp 801 Bytes
Newer Older
Matthieu Dorier's avatar
Matthieu Dorier committed
1 2 3 4 5 6 7
/*
 * (C) 2017 The University of Chicago
 * 
 * See COPYRIGHT in top-level directory.
 */
#ifndef __THALLIUM_UNORDERED_MULTIMAP_SERIALIZATION_HPP
#define __THALLIUM_UNORDERED_MULTIMAP_SERIALIZATION_HPP
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38

#include <unordered_map>

namespace thallium {

template<class A, typename K, typename V, class Hash, class Pred, class Alloc>
void save(A& ar, std::unordered_multimap<K,V,Hash,Pred,Alloc>& m) {
	size_t size = m.size();
	ar.write(&size);
	for(auto& elem : m) {
		ar & elem.first;
		ar & elem.second;
	}
}

template<class A, typename K, typename V, class Hash, class Pred, class Alloc>
void load(A& ar, std::unordered_multimap<K,V,Hash,Pred,Alloc>& m) {
	size_t size;
	ar.read(&size);
	m.clear();
	m.reserve(size);
	for(unsigned int i=0; i<size; i++) {
		K k;
		ar & k;
		ar & m[k];
	}
}

}

#endif