Core: Expand std::initializer_list support

This commit is contained in:
Thaddeus Crews
2024-08-21 13:32:25 -05:00
parent fafc07335b
commit 361e3b4fe8
17 changed files with 177 additions and 9 deletions

View File

@@ -37,6 +37,8 @@
#include "core/templates/paged_allocator.h"
#include "core/templates/pair.h"
#include <initializer_list>
/**
* A HashMap implementation that uses open addressing with Robin Hood hashing.
* Robin Hood hashing swaps out entries that have a smaller probing distance
@@ -640,6 +642,13 @@ public:
capacity_index = MIN_CAPACITY_INDEX;
}
HashMap(std::initializer_list<KeyValue<TKey, TValue>> p_init) {
reserve(p_init.size());
for (const KeyValue<TKey, TValue> &E : p_init) {
insert(E.key, E.value);
}
}
uint32_t debug_get_hash(uint32_t p_index) {
if (num_elements == 0) {
return 0;