Skip to content

mannikim/mkhas.h

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

mkhas.h

single-header hash table implementation

features

  • c99
  • uses FNV-1a hash algorithm
  • uses linked lists to solve collisions
  • no dependencies other than libc
  • v2.0 now uses uses error codes where it can (no more "result" struct, less rust-like, more c-like)
  • v2.0 now does no memory allocations
  • v2.0 implments key hashing for u64 integers

usage

install

copy and paste mkhas.h into your project

in a single c source file, include the header like this:

#define mkhas_IMPL
#include "mkhas.h"

this will load all implementations of the functions in the source file

you can now compile it and use the table

example

see examples in example.c and the test scripts

building

use make example to build the example

use make test to build and run all tests

issues

  • the mkhas_free and mkhas_delete functions might crash the program if used incorrectly
  • i have not implemented results in the mkhas_remove and mkhas_clear functions since i'm assuming the existence of the key implies a successful insertion. creating keys outside of mkhas_get isn't recommended

license and copyright

licensed under the GNU GPLv3.0 or any later version, at your option. see LICENSE file for license and copyright information

About

single-header hash table implementation

Topics

Resources

License

Stars

Watchers

Forks