Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int containsKey (struct hashMap * ht, KeyType k)
- {
- assert(ht != NULL);
- int hashIndex;
- if (HASHING_FUNCTION == 1) {
- hashIndex = stringHash1(k) % ht->tableSize;
- }
- if (HASHING_FUNCTION == 2) {
- hashIndex = stringHash2(k) % ht->tableSize;
- }
- if (hashIndex < 0) {
- hashIndex += ht->tableSize;
- }
- struct hashLink *searchLink = ht->table[hashIndex];
- while(searchLink != NULL) {
- if (strcmp(searchLink->key, k) == 0) {
- return 1;
- }
- searchLink = searchLink->next;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement