Add MixPolicy template parameter to unordered_flat_map and foa::table

This commit is contained in:
Peter Dimov
2022-12-08 22:15:43 +02:00
parent 7040c57750
commit afbaf9361d
3 changed files with 38 additions and 34 deletions

View File

@ -786,7 +786,7 @@ inline unsigned int unchecked_countr_zero(int x)
#endif
}
template<typename,typename,typename,typename>
template<typename,typename,typename,typename,typename>
class table;
/* table_iterator keeps two pointers:
@ -850,7 +850,7 @@ public:
private:
template<typename,typename,bool> friend class table_iterator;
template<typename,typename,typename,typename> friend class table;
template<typename,typename,typename,typename,typename> friend class table;
table_iterator(Group* pg,std::size_t n,const Value* p_):
pc{reinterpret_cast<unsigned char*>(const_cast<Group*>(pg))+n},
@ -1112,7 +1112,7 @@ inline void prefetch(const void* p)
*/
constexpr static float const mlf = 0.875f;
template<typename TypePolicy,typename Hash,typename Pred,typename Allocator>
template<typename TypePolicy,typename Hash,typename Pred,typename Allocator,typename MixPolicy=xmx_mix>
class
#if defined(_MSC_VER)&&_MSC_FULL_VER>=190023918
@ -1132,7 +1132,7 @@ table:empty_value<Hash,0>,empty_value<Pred,1>,empty_value<Allocator,2>
using mix_policy=typename std::conditional<
hash_is_avalanching<Hash>::value,
no_mix,
xmx_mix
MixPolicy
>::type;
using alloc_traits=boost::allocator_traits<Allocator>;
@ -1491,7 +1491,7 @@ public:
}
private:
template<typename,typename,typename,typename> friend class table;
template<typename,typename,typename,typename,typename> friend class table;
using arrays_type=table_arrays<value_type,group_type,size_policy>;
struct clear_on_exit

View File

@ -32,7 +32,7 @@ namespace boost {
#pragma warning(disable : 4714) /* marked as __forceinline not inlined */
#endif
template <class Key, class T, class Hash, class KeyEqual, class Allocator>
template <class Key, class T, class Hash, class KeyEqual, class Allocator, class MixPolicy>
class unordered_flat_map
{
struct map_types
@ -61,13 +61,13 @@ namespace boost {
using table_type = detail::foa::table<map_types, Hash, KeyEqual,
typename boost::allocator_rebind<Allocator,
typename map_types::value_type>::type>;
typename map_types::value_type>::type, MixPolicy>;
table_type table_;
template <class K, class V, class H, class KE, class A, class Pred>
typename unordered_flat_map<K, V, H, KE, A>::size_type friend erase_if(
unordered_flat_map<K, V, H, KE, A>& set, Pred pred);
template <class K, class V, class H, class KE, class A, class MP, class Pred>
typename unordered_flat_map<K, V, H, KE, A, MP>::size_type friend erase_if(
unordered_flat_map<K, V, H, KE, A, MP>& set, Pred pred);
public:
using key_type = Key;
@ -387,7 +387,7 @@ namespace boost {
template <class H2, class P2>
void merge(
unordered_flat_map<key_type, mapped_type, H2, P2, allocator_type>&
unordered_flat_map<key_type, mapped_type, H2, P2, allocator_type, MixPolicy>&
source)
{
table_.merge(source.table_);
@ -395,7 +395,7 @@ namespace boost {
template <class H2, class P2>
void merge(
unordered_flat_map<key_type, mapped_type, H2, P2, allocator_type>&&
unordered_flat_map<key_type, mapped_type, H2, P2, allocator_type, MixPolicy>&&
source)
{
table_.merge(std::move(source.table_));
@ -579,10 +579,10 @@ namespace boost {
key_equal key_eq() const { return table_.key_eq(); }
};
template <class Key, class T, class Hash, class KeyEqual, class Allocator>
template <class Key, class T, class Hash, class KeyEqual, class Allocator, class MixPolicy>
bool operator==(
unordered_flat_map<Key, T, Hash, KeyEqual, Allocator> const& lhs,
unordered_flat_map<Key, T, Hash, KeyEqual, Allocator> const& rhs)
unordered_flat_map<Key, T, Hash, KeyEqual, Allocator, MixPolicy> const& lhs,
unordered_flat_map<Key, T, Hash, KeyEqual, Allocator, MixPolicy> const& rhs)
{
if (&lhs == &rhs) {
return true;
@ -599,27 +599,27 @@ namespace boost {
})();
}
template <class Key, class T, class Hash, class KeyEqual, class Allocator>
template <class Key, class T, class Hash, class KeyEqual, class Allocator, class MixPolicy>
bool operator!=(
unordered_flat_map<Key, T, Hash, KeyEqual, Allocator> const& lhs,
unordered_flat_map<Key, T, Hash, KeyEqual, Allocator> const& rhs)
unordered_flat_map<Key, T, Hash, KeyEqual, Allocator, MixPolicy> const& lhs,
unordered_flat_map<Key, T, Hash, KeyEqual, Allocator, MixPolicy> const& rhs)
{
return !(lhs == rhs);
}
template <class Key, class T, class Hash, class KeyEqual, class Allocator>
void swap(unordered_flat_map<Key, T, Hash, KeyEqual, Allocator>& lhs,
unordered_flat_map<Key, T, Hash, KeyEqual, Allocator>& rhs)
template <class Key, class T, class Hash, class KeyEqual, class Allocator, class MixPolicy>
void swap(unordered_flat_map<Key, T, Hash, KeyEqual, Allocator, MixPolicy>& lhs,
unordered_flat_map<Key, T, Hash, KeyEqual, Allocator, MixPolicy>& rhs)
noexcept(noexcept(lhs.swap(rhs)))
{
lhs.swap(rhs);
}
template <class Key, class T, class Hash, class KeyEqual, class Allocator,
template <class Key, class T, class Hash, class KeyEqual, class Allocator, class MixPolicy,
class Pred>
typename unordered_flat_map<Key, T, Hash, KeyEqual, Allocator>::size_type
typename unordered_flat_map<Key, T, Hash, KeyEqual, Allocator, MixPolicy>::size_type
erase_if(
unordered_flat_map<Key, T, Hash, KeyEqual, Allocator>& map, Pred pred)
unordered_flat_map<Key, T, Hash, KeyEqual, Allocator, MixPolicy>& map, Pred pred)
{
return erase_if(map.table_, pred);
}

View File

@ -18,24 +18,28 @@
namespace boost {
namespace unordered {
namespace detail { namespace foa { struct xmx_mix; } }
template <class Key, class T, class Hash = boost::hash<Key>,
class KeyEqual = std::equal_to<Key>,
class Allocator = std::allocator<std::pair<const Key, T> > >
class Allocator = std::allocator<std::pair<const Key, T> >,
class MixPolicy = detail::foa::xmx_mix >
class unordered_flat_map;
template <class Key, class T, class Hash, class KeyEqual, class Allocator>
template <class Key, class T, class Hash, class KeyEqual, class Allocator, class MixPolicy>
bool operator==(
unordered_flat_map<Key, T, Hash, KeyEqual, Allocator> const& lhs,
unordered_flat_map<Key, T, Hash, KeyEqual, Allocator> const& rhs);
unordered_flat_map<Key, T, Hash, KeyEqual, Allocator, MixPolicy> const& lhs,
unordered_flat_map<Key, T, Hash, KeyEqual, Allocator, MixPolicy> const& rhs);
template <class Key, class T, class Hash, class KeyEqual, class Allocator>
template <class Key, class T, class Hash, class KeyEqual, class Allocator, class MixPolicy>
bool operator!=(
unordered_flat_map<Key, T, Hash, KeyEqual, Allocator> const& lhs,
unordered_flat_map<Key, T, Hash, KeyEqual, Allocator> const& rhs);
unordered_flat_map<Key, T, Hash, KeyEqual, Allocator, MixPolicy> const& lhs,
unordered_flat_map<Key, T, Hash, KeyEqual, Allocator, MixPolicy> const& rhs);
template <class Key, class T, class Hash, class KeyEqual, class Allocator>
void swap(unordered_flat_map<Key, T, Hash, KeyEqual, Allocator>& lhs,
unordered_flat_map<Key, T, Hash, KeyEqual, Allocator>& rhs)
template <class Key, class T, class Hash, class KeyEqual, class Allocator, class MixPolicy>
void swap(unordered_flat_map<Key, T, Hash, KeyEqual, Allocator, MixPolicy>& lhs,
unordered_flat_map<Key, T, Hash, KeyEqual, Allocator, MixPolicy>& rhs)
noexcept(noexcept(lhs.swap(rhs)));
} // namespace unordered