A small hash table project I built to practice core data structure behavior in modern C++.
It supports:
- insert / update
- search
- delete
- printing table contents
- resizing up and down
Internally it uses:
std::unique_ptrfor memory safety- open addressing with linear probing
- prime-sized table growth/shrink
I wanted a version of a hash table that’s simple enough to read, but still close to how a real one works (collisions, probing, load factor, resizing).
src/hash_table.h— structs + function declarationssrc/hash_table.cpp— hash table logicsrc/prime.h/src/prime.cpp— prime helpers for resize targetssrc/main.cpp— console menu to try operations interactively
From the project root:
cmake -S . -B build cmake --build build --config Release
Run:
.\build\Release\main.exeThe app currently has options for:
- Insert/Update key-value
- Search key
- Delete key
- Print table
- Resize UP (manual)
- Resize DOWN (manual)
- Exit
unique_ptrhandles memory cleanup automatically.- A delete operation is still needed for hash-table behavior (not memory behavior).
- Search currently returns an empty string when not found, so empty-string values can be ambiguous.
- Add tombstone handling for delete in linear probing
- Return
bool/std::optional<std::string>from search - Add unit tests for insert/search/delete/resize
- Add automatic resize thresholds only (remove manual menu options)
MIT