Deluge Firmware
1.3.0
Build date: 2026.08.29
Toggle main menu visibility
Loading...
Searching...
No Matches
open_addressing_hash_table.h
1
/*
2
* Copyright © 2020-2023 Synthstrom Audible Limited
3
*
4
* This file is part of The Synthstrom Audible Deluge Firmware.
5
*
6
* The Synthstrom Audible Deluge Firmware is free software: you can redistribute it and/or modify it under the
7
* terms of the GNU General Public License as published by the Free Software Foundation,
8
* either version 3 of the License, or (at your option) any later version.
9
*
10
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
11
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12
* See the GNU General Public License for more details.
13
*
14
* You should have received a copy of the GNU General Public License along with this program.
15
* If not, see <https://www.gnu.org/licenses/>.
16
*/
17
18
#pragma once
19
#include <cstdint>
20
21
class
OpenAddressingHashTable {
22
public
:
23
OpenAddressingHashTable();
24
virtual
~OpenAddressingHashTable();
25
virtual
uint32_t getKeyFromAddress(
void
* address) = 0;
26
virtual
void
setKeyAtAddress(uint32_t key,
void
* address) = 0;
27
virtual
bool
doesKeyIndicateEmptyBucket(uint32_t key) = 0;
28
29
int32_t getBucketIndex(uint32_t key);
30
void
* getBucketAddress(int32_t b);
31
void
* secondaryMemoryGetBucketAddress(int32_t b);
32
void
* insert(uint32_t key,
bool
* onlyIfNotAlreadyPresent =
nullptr
);
33
void
* lookup(uint32_t key);
34
bool
remove(uint32_t key);
35
void
empty(
bool
destructing =
false
);
36
37
void
* memory;
38
int32_t numBuckets;
39
int32_t numElements;
40
41
void
* secondaryMemory;
42
int32_t secondaryMemoryNumBuckets;
43
uint32_t secondaryMemoryFunctionCurrentIteration;
44
uint8_t secondaryMemoryCurrentFunction;
45
46
int8_t elementSize;
47
int8_t initialNumBuckets;
48
};
49
50
class
OpenAddressingHashTableWith32bitKey final :
public
OpenAddressingHashTable {
51
public
:
52
OpenAddressingHashTableWith32bitKey();
53
uint32_t getKeyFromAddress(
void
* address)
override
;
54
void
setKeyAtAddress(uint32_t key,
void
* address)
override
;
55
bool
doesKeyIndicateEmptyBucket(uint32_t key)
override
;
56
};
57
58
class
OpenAddressingHashTableWith16bitKey final :
public
OpenAddressingHashTable {
59
public
:
60
OpenAddressingHashTableWith16bitKey();
61
uint32_t getKeyFromAddress(
void
* address)
override
;
62
void
setKeyAtAddress(uint32_t key,
void
* address)
override
;
63
bool
doesKeyIndicateEmptyBucket(uint32_t key)
override
;
64
};
65
66
class
OpenAddressingHashTableWith8bitKey final :
public
OpenAddressingHashTable {
67
public
:
68
OpenAddressingHashTableWith8bitKey();
69
uint32_t getKeyFromAddress(
void
* address)
override
;
70
void
setKeyAtAddress(uint32_t key,
void
* address)
override
;
71
bool
doesKeyIndicateEmptyBucket(uint32_t key)
override
;
72
};