32-bit integer hash set header library
Switch branches/tags
Nothing to show
Clone or download
Latest commit 2ee7aa6 Oct 5, 2017
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.gitignore Initial working hash set library. Aug 29, 2017
Makefile Initial working hash set library. Aug 29, 2017
README.md Initial working hash set library. Aug 29, 2017
UNLICENSE Initial working hash set library. Aug 29, 2017
set32.h Fix macro names Oct 5, 2017
test.c Use _POSIX_C_SOURCE 200112L to get CLOCK_MONOTONIC Sep 24, 2017

README.md

C99 32-bit integer hash set header library

This is a public domain header library defining a fast, lightweight integer hash set. It uses closed hashing and makes no allocations of its own. The API is dead simple:

int      set32_z(uint32_t max);
uint32_t set32_hash(uint32_t);
void     set32_insert(uint32_t *table, int z, uint32_t v);
void     set32_remove(uint32_t *table, int z, uint32_t v);
int      set32_contains(uint32_t *table, int z, uint32_t v);

The set32_z() function returns the appropriate power-of-two table size for the given maximum number of set elements. It's up to the caller to allocate and zero-initialize this buffer. The hash set is unable to store the value 0.