3#ifndef TRAM_SDK_TEMPLATES_HASHMAP_H
4#define TRAM_SDK_TEMPLATES_HASHMAP_H
31 char* memory = (
char*)::
operator new(memory_size);
36 memset(memory, 0, memory_size);
40 for (
const auto& entry : list) {
41 Insert(entry.first, entry.second);
54 while (candidate !=
last) {
59 if (candidate->
key == key) {
63 return candidate->
value;
83 while (candidate !=
last) {
88 if (candidate->
key == key) {
109 std::cout <<
"Hashmap " <<
name <<
" density reached!" << std::endl;
116 while (candidate !=
last) {
118 if (candidate->
key == key) {
119 candidate->
value.~T();
135 if (candidate ==
last) {
136 std::cout <<
"Hashmap " <<
name <<
" overflow!" << std::endl;
142 candidate->
key = key;
143 candidate->
value = value;
156 while (candidate !=
last) {
161 if (candidate->
key == key) {
165 candidate->
value.~T();
186 while (candidate !=
last) {
187 if (candidate->
key == key) {
188 return candidate->
value;
203 if (candidate ==
last) {
204 std::cout <<
"Hashmap " <<
name <<
" overflow!" << std::endl;
211 std::cout <<
"Hashmap " <<
name <<
" density reached!" << std::endl;
214 candidate->
key = key;
215 candidate->
value = T();
218 return candidate->
value;
Record * last
Definition: hashmap.h:239
size_t max_size
Definition: hashmap.h:236
T & operator[](UID key)
Definition: hashmap.h:177
T & operator[](uint32_t key)
Definition: hashmap.h:181
const size_t padding
Definition: hashmap.h:227
constexpr Hashmap(std::string name, size_t max_size)
Definition: hashmap.h:24
size_t size
Definition: hashmap.h:235
void Insert(UID key, T value)
Definition: hashmap.h:103
bool Exists(UID key)
Definition: hashmap.h:74
void Insert(uint32_t key, T value)
Definition: hashmap.h:107
T Find(UID key)
Definition: hashmap.h:45
@ FLAG_DELETED
Definition: hashmap.h:231
@ FLAG_RECORD
Definition: hashmap.h:230
bool Exists(uint32_t key)
Definition: hashmap.h:78
std::string name
Definition: hashmap.h:234
constexpr Hashmap(std::string name, size_t max_size, std::initializer_list< std::pair< uint32_t, T > > list)
Definition: hashmap.h:39
void Remove(UID key)
Definition: hashmap.h:147
void Remove(uint32_t key)
Definition: hashmap.h:151
Record * first
Definition: hashmap.h:238
uint32_t hash_parameter
Definition: hashmap.h:237
T Find(uint32_t key)
Definition: hashmap.h:49
Definition: hashmap.h:222
uint32_t flags
Definition: hashmap.h:224
T value
Definition: hashmap.h:225
uint32_t key
Definition: hashmap.h:223
Interned string type.
Definition: uid.h:10
uint32_t key
Definition: uid.h:40