Created
November 25, 2015 23:53
-
-
Save dean/d0eb0e649dce295e18df to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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