Untitled

 avatar
unknown
plain_text
a year ago
510 B
5
Indexable
hashmap* map = hashmap_new(sizeof(char*), sizeof(int), 0, hash_string, compare_string, NULL, NULL);
hashmap_set(map, &(char*){"friday"}, &(int){1});
hashmap_set(map, &(char*){"fridays"}, &(int){1});
hashmap_remove(map, &(char*){"friday"});
hashmap_set(map, &(char*){"fridays"}, &(int){2});

size_t i = 0;
void* k = NULL;
void* v = NULL;
while (hashmap_next(map, &i, &k, &v)) 
{
	char* key = *(char**)k;
	int val = *(int*)v;
	printf("{key -> %s : val -> %d}\n", key, val); 
}

hashmap_free(map);
Editor is loading...
Leave a Comment