Exemple #1
0
void main()
{
	hashmap *hMap;
	hMap = hmap_creat(int_hash_fn, int_eq_fn, int_del_fn);

	if(!hmap_put(hMap, (void*)"test", (void*)"value"))
		return;
	printf( "%s\n", (char*)hmap_get(hMap, (void*)"test") );
	free_hmap(hMap);
	hMap = NULL;
}
Exemple #2
0
int main() {
	hashmap* h = mk_hmap(str_hash_fn, str_eq_fn, str_del_fn);
	
	char* s = (char*) malloc(8);
	char* k = (char*) malloc(8); 
	
	sprintf(s, "hello"); 
	sprintf(k, "world"); 
	
	hmap_add(h, s, k); // map "hello" to "world"
	hmap_add(h, k, s); // map "world" to "hello"
	
	char* x = (char*) hmap_get(h, k);
	printf("%s ", x);
	
	x = (char*) hmap_get(h, s);
	printf("%s!\n", x);
	
	free_hmap(h);
	
	return 0;
}