/* Adds a key-value pair to a map. */ void map_add(Map *map, Hashable *key, Value *value) { int hashval = hash_hashable(key) % map->n; Node *list = map->lists[hashval]; map->lists[hashval] = prepend(key, value, list); }
/* Looks up a key and returns the corresponding value, or NULL. */ Value *map_lookup(Map *map, Hashable *key) { int hashval = hash_hashable(key) % map->n; Node *list = map->lists[hashval]; return list_lookup(list, key); }
/* Finds which list a key is in */ int map_index(Map *map, Hashable *key) { unsigned int hash, step; hash = (unsigned int) hash_hashable(key); step = UINT_MAX / map->n; return (int) (hash / step); }
/* Looks up a key and returns the corresponding value, or NULL. */ Value *map_lookup(Map *map, Hashable *key) { int index; Node *list; index = hash_hashable(key) % map->n; list = (map->lists)[index]; return list_lookup(list, key); }
/* Adds a key-value pair to a map. */ void map_add(Map *map, Hashable *key, Value *value) { // FIX ME! done int index; Node *list; index = hash_hashable(key) % map->n; list = (map->lists)[index]; (map->lists)[index] = make_node(key, value, list); }
/* Looks up a key and returns the corresponding value, or NULL. */ Value *map_lookup(Map *map, Hashable *key) { int hashValue = hash_hashable(key); if(hashValue > map->n - 1){ hashValue = hashValue % (map->n -1); } if (map->lists[hashValue]){ return list_lookup(map->lists[hashValue],key); } return NULL; }
/* Adds a key-value pair to a map. */ void map_add(Map *map, Hashable *key, Value *value) { int hashValue = hash_hashable(key); if(hashValue > map->n - 1){ hashValue = hashValue % (map->n -1); } if(map->lists[hashValue]) { Node *checkNode = map->lists[hashValue]; while(checkNode->next){ checkNode = checkNode->next; } checkNode->next = make_node(key, value, NULL); }else{ map->lists[hashValue] = make_node(key, value, NULL); } }
/* Adds a key-value pair to a map. */ void map_add(Map *map, Hashable *key, Value *value) { int hashed_val = hash_hashable(key); if }
int get_map_index(Map *map, Hashable *key) { return hash_hashable(key) % map->n; }