A hashset implementation that uses contiguous memory space. This allows you to
build large sets and load them at runtime using mmap
.
Refer to hashset.h
for the complete interface.
#include "hashset.h"
int main() {
set *ptr = NULL;
set_alloc(&ptr, 5*1024, 20*1024, hasher);
set_add(ptr, "abc", sizeof("abc"));
assert(0 == set_find(ptr, "abc", sizeof("abc")));
return 0;
}
Refer to preprocess.c
and level0.c
for examples.
preprocess
reads a dictionary of words and adds them to a hashset that is
persisted to disk.
$ make examples/preprocess
$ examples/preprocess
level0
is a spellchecker that uses the blob created by preprocess
.
$ make examples/level0
$ examples/level0
this is a corect string
this is a <corect> string
Tests live in tests/
. To run them, use
$ make test