4#ifndef TRAM_SDK_TEMPLATES_HASHMAP_H
5#define TRAM_SDK_TEMPLATES_HASHMAP_H
21 char* memory = (
char*)::
operator new(memory_size);
24 last = (
PAIR*) (memory + memory_size);
30 for (
const auto& entry : list) {
31 Insert(entry.first, entry.second);
44 while (candidate !=
last) {
45 if (candidate->first == key) {
46 return candidate->second;
49 if (candidate->first == 0) {
65 std::cout <<
"Hashmap " <<
name <<
" density reached!" << std::endl;
72 while (candidate !=
last) {
73 if (candidate->first == key) {
74 candidate->second.~T();
78 if (candidate->first == 0) {
85 if (candidate ==
last) {
86 std::cout <<
"Hashmap " <<
name <<
" overflow!" << std::endl;
90 candidate->first = key;
91 candidate->second = value;
94 typedef std::pair<uint64_t, T>
PAIR;
size_t max_size
Definition: hashmap.h:99
Hashmap(std::string name, size_t max_size)
Definition: hashmap.h:15
const size_t padding
Definition: hashmap.h:95
size_t size
Definition: hashmap.h:98
std::pair< uint64_t, T > PAIR
Definition: hashmap.h:94
void Insert(UID key, T value)
Definition: hashmap.h:59
T Find(UID key)
Definition: hashmap.h:35
PAIR * last
Definition: hashmap.h:101
std::string name
Definition: hashmap.h:97
T Find(uint64_t key)
Definition: hashmap.h:39
Hashmap(std::string name, size_t max_size, std::initializer_list< std::pair< uint64_t, T > > list)
Definition: hashmap.h:29
PAIR * first
Definition: hashmap.h:100
void Insert(uint64_t key, T value)
Definition: hashmap.h:63
uint32_t key
Definition: uid.h:37