Skip to content

Instantly share code, notes, and snippets.

@dean
Created November 25, 2015 23:53
Show Gist options
  • Save dean/d0eb0e649dce295e18df to your computer and use it in GitHub Desktop.
Save dean/d0eb0e649dce295e18df to your computer and use it in GitHub Desktop.
void insertMap(struct hashMap * ht, KeyValue key, ValueType value) {
int index = stringHash2(k) % tableSize;
struct hashLink *cur; = hashMap[index];
int same = strcmp(cur->key, key);
while (cur != NULL || !same) {
cur = hashMap[index]->next;
same = strcmp(cur->key, key);
}
int createNewLink = cur == NULL;
if (createNewLink) {
ht->count++;
struct hashLink *newLink = (struct hashLink*) malloc(sizeof(hashLink));
newLink->key = key;
newLink->next = NULL;
cur = newLink;
}
cur->value = value;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment