Skip to content

andydevs69420/hashmap-C

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

hashmap-C

HashMap implementation in C programming language.

Description 🔥

Simple HashMap implementation in C programming language.
Uses char* datatype as key and value.

USAGE:

#include "hashmap.h"

int main(int argc, char **args) 
{
    /*
     | Test
     | describe: test hashmap with hex colors.
     */

    HashMap *colors = new_HashMap();
    colors->put(colors, "Yellow", "#ffff00");
    colors->put(colors, "Blue"  , "#0000ff");
    colors->put(colors, "White" , "#ffffff");

    char *hexval = colors->get(colors, "Blue");
    printf("Blue: %s\n", hexval);

    hexval = colors->get(colors, "White");
    printf("White: %s\n", hexval);

    hexval = colors->get(colors, "Yellow");
    printf("Yellow: %s\n", hexval);

    /** OUTPUT: 
        $ ./compile-linux.sh 
        Blue: #0000ff
        White: #ffffff
        Yellow: #ffff00
    **/

    colors->get(colors, "Green");
    /** OUTPUT: 
        $ ./compile-linux.sh 
        Blue: #0000ff
        White: #ffffff
        Yellow: #ffff00
        KeyError: key "Green" does not exist !!!
    **/

    free(colors);
    return 0;
}

About

HashMap implementation in C programming language.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published