Skip to content
/ hashmap Public

Simple hashmap in C using FNV-1a and linked lists for collisions

Notifications You must be signed in to change notification settings

prismz/hashmap

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

hashmap
-------
A simple hashmap in C. No license because I don't care enough - do whatever you
want with it. Uses FNV-1a hash and handles collisions through linked lists.
Values are simply stored as (void *), which means you can store a pointer
to whatever you want. Just remember what kind of data you're working with
and typecast accordingly when retrieving values.

READ THE HEADER FILE and change the options for your use case.

If any issues arise, simply open an issue.

Creating a Hashmap
------------------
Call hashmap_new(val_free_func).
val_free_func is should be a function that frees your values.
Use the macro hashmap_item_free_func() on your function to typecast it.

Creating and Adding an Item
------------------------------------
hashmap_insert(map, "key", value).

Retrieving an Item
------------------
Call hashmap_get(map, key).

Removing an Item
----------------
Call hashmap_remove(map, key);

Freeing
-------
Simply call hashmap_free(map) and everything should be freed recursively.

Return Values
-------------
Functions return 0 on success, and 1 on error.

About

Simple hashmap in C using FNV-1a and linked lists for collisions

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published