https://github.com/vi/macro_robinhood_hash
Simple Robin Hood hash table implemented using C macros
https://github.com/vi/macro_robinhood_hash
Last synced: about 1 year ago
JSON representation
Simple Robin Hood hash table implemented using C macros
- Host: GitHub
- URL: https://github.com/vi/macro_robinhood_hash
- Owner: vi
- License: mit
- Created: 2017-10-27T04:02:45.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2025-02-07T15:19:21.000Z (over 1 year ago)
- Last Synced: 2025-04-15T14:13:39.583Z (about 1 year ago)
- Language: C
- Size: 12.7 KB
- Stars: 14
- Watchers: 3
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# macro_robinhood_hash
Flexible C macros implementation of fixed size array-based Robin Hood hash table with backward-shift deletion.
Implemented by Vitaly "_Vi" Shukela in 2017. License = MIT or Apache 2.0.
Don't shrink this hash table by sequentially iterating it and inserting elements into a smaller table.
## Examples
* example.c - basic int-to-char table
* example_stringkeys.c - chararray-keyed table
* fuzzer.cpp - checks integrity of the table by issuing random operations and comparing with std::set
## How to use
* Design the table, so each cell can be easily checked for emptiness, keys stored inside cells somehow and preferred bucket number (i.e. hash) is easily gettable from a key (or even stored inside). One value should be designated to mean empty cell. Zeroeth bucket is also reserved for newly incoming entries and is never preferred.
* Implement elementrary functions for getting keys and/or values, checking for emptiness, swapping two cell contents and so on using C macros prefixed with some your prefix
* Use ROBINHOOD_HASH_* macros, specifying that prefix. "u" is just argument for all your macros.