#pragma once #include #include template < typename Key, typename Cell, typename Hash = DefaultHash, typename Grower = TwoLevelHashTableGrower<>, typename Allocator = HashTableAllocator, template typename ImplTable = HashMapTable > class TwoLevelHashMapTable : public TwoLevelHashTable> { public: using Impl = ImplTable; using LookupResult = typename Impl::LookupResult; using TwoLevelHashTable>::TwoLevelHashTable; template void ALWAYS_INLINE forEachMapped(Func && func) { for (auto i = 0u; i < this->NUM_BUCKETS; ++i) this->impls[i].forEachMapped(func); } typename Cell::Mapped & ALWAYS_INLINE operator[](const Key & x) { LookupResult it; bool inserted; this->emplace(x, it, inserted); if (inserted) new (&it->getMapped()) typename Cell::Mapped(); return it->getMapped(); } }; template < typename Key, typename Mapped, typename Hash = DefaultHash, typename Grower = TwoLevelHashTableGrower<>, typename Allocator = HashTableAllocator, template typename ImplTable = HashMapTable > using TwoLevelHashMap = TwoLevelHashMapTable, Hash, Grower, Allocator, ImplTable>; template < typename Key, typename Mapped, typename Hash = DefaultHash, typename Grower = TwoLevelHashTableGrower<>, typename Allocator = HashTableAllocator, template typename ImplTable = HashMapTable > using TwoLevelHashMapWithSavedHash = TwoLevelHashMapTable, Hash, Grower, Allocator, ImplTable>;