From df7792040cffac302a90befca467086e623cbf1c Mon Sep 17 00:00:00 2001 From: joaquintides Date: Wed, 12 Oct 2022 11:18:05 +0200 Subject: [PATCH] implemented merge --- include/boost/unordered/detail/foa.hpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/include/boost/unordered/detail/foa.hpp b/include/boost/unordered/detail/foa.hpp index 8d5a258b..ac142209 100644 --- a/include/boost/unordered/detail/foa.hpp +++ b/include/boost/unordered/detail/foa.hpp @@ -1182,6 +1182,20 @@ public: size_=0; } + // TODO: should we accept different allocator too? + template + void merge(table& x) + { + x.for_all_elements([&,this](group_type* pg,unsigned int n,value_type* p){ + if(emplace_impl(type_policy::move(*p)).second){ + x.erase(iterator{pg,n,p}); + } + }); + } + + template + void merge(table&& x){merge(x);} + hasher hash_function()const{return h();} key_equal key_eq()const{return pred();} @@ -1226,6 +1240,7 @@ public: } private: + template friend class table; using arrays_type=table_arrays; Hash& h(){return hash_base::get();}