Skip to content

A simple string-to-string hashtable implementation in C using the FNV-1a hash function

Notifications You must be signed in to change notification settings

ajgae/hashtable-c

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

C Hashtable Implementation

This is a simple implementation of a string-to-string hashtable (both keys and values are strings). The hash function used is FNV-1a. Collision resolution is done using linear probing.

Compilation

The prompt can use readline for autocompletion of commands and better line editing capacities. Otherwise, a homebrewed prompt implementation will be used, which should work but isn't as nice to use.

  • with readline: gcc hashtable.c prompt.c main.c -D _USE_READLINE -lreadline
  • without readline: gcc hashtable.c prompt.c main.c

Usage

The user is presented with a simple prompt. A few commands can be issued. Arguments are space or tab-separated, with no support for including whitespace characters in arguments yet.

  • exit, quit or q: exit the program.
  • put: add the given key-value pair to the hashtable. Requires two arguments (key and value).
  • remove: attempt to remove the entry with the given key from the hashtable. Requires one argument (key).
  • show: display information about the hashtable, such as capacity, load factor, and existing key-value pairs. Requires zero arguments.
  • hash: display the hash value of the first argument in base 16. If there is a second argument, and it is a valid positive non-zero integer, show hash of first argument modulo second argument, in base 10.

About

A simple string-to-string hashtable implementation in C using the FNV-1a hash function

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages