Skip to content

jumbuna/MAP

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MAP

DESCRIPTION

A general purpose hashmap in c.

INSTALLING

Currently the only way to obtain this library is by building from source, described in the next section.

BUILDING

Requirements:

$ cd /path/to/repo/clone
$ cmake -B build
$ cmake --build build
# optional
$ cmake --build build --target install

EXAMPLES

typedef struct Map map;
typedef struct Person {
    char name[20];
    int age;
} person;
extern hashadd(char*);
map *mp = mapcreate(10, hashadd, strcmp, sizeof(person));
person *p = mapmalloc(mp);
strcpy(p->name, "jumbuna");
p->age = 100;
mapadd(mp, p);
mapsize(mp); // 1
person *x = mapfind(mp, "jumbuna");
assert(p == x);
/* remove 'jumbuna' from map */
mapremove(mp, p);
/* release 'jumbuna' memory */
mapfree(mp, p);

CONTRIBUTIONS

All contributions are welcome. Send me a pull request anytime.

About

A General purpose map.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published