@@ -66,14 +66,13 @@ template <typename TKey, typename TValue,
6666 typename Hasher = HashMapHasherDefault,
6767 typename Comparator = HashMapComparatorDefault<TKey>,
6868 typename Allocator = DefaultTypedAllocator<HashMapElement<TKey, TValue>>>
69- class HashMap {
69+ class HashMap : private Allocator {
7070public:
7171 static constexpr uint32_t MIN_CAPACITY_INDEX = 2 ; // Use a prime.
7272 static constexpr float MAX_OCCUPANCY = 0.75 ;
7373 static constexpr uint32_t EMPTY_HASH = 0 ;
7474
7575private:
76- Allocator element_alloc;
7776 HashMapElement<TKey, TValue> **elements = nullptr ;
7877 uint32_t *hashes = nullptr ;
7978 HashMapElement<TKey, TValue> *head_element = nullptr ;
@@ -214,7 +213,7 @@ class HashMap {
214213 _resize_and_rehash (capacity_index + 1 );
215214 }
216215
217- HashMapElement<TKey, TValue> *elem = element_alloc. new_allocation (HashMapElement<TKey, TValue>(p_key, p_value));
216+ HashMapElement<TKey, TValue> *elem = Allocator:: new_allocation (HashMapElement<TKey, TValue>(p_key, p_value));
218217
219218 if (tail_element == nullptr ) {
220219 head_element = elem;
@@ -254,7 +253,7 @@ class HashMap {
254253 }
255254
256255 hashes[i] = EMPTY_HASH;
257- element_alloc. delete_allocation (elements[i]);
256+ Allocator:: delete_allocation (elements[i]);
258257 elements[i] = nullptr ;
259258 }
260259
@@ -379,7 +378,7 @@ class HashMap {
379378 elements[pos]->next ->prev = elements[pos]->prev ;
380379 }
381380
382- element_alloc. delete_allocation (elements[pos]);
381+ Allocator:: delete_allocation (elements[pos]);
383382 elements[pos] = nullptr ;
384383
385384 num_elements--;
0 commit comments