Skip to content

Instantly share code, notes, and snippets.

@rbriank
Created January 4, 2012 14:53
Show Gist options
  • Save rbriank/1560362 to your computer and use it in GitHub Desktop.
Save rbriank/1560362 to your computer and use it in GitHub Desktop.
#define PTR_NOT_EQUAL(table, ptr, hash_val, key) \
((ptr) != 0 && (ptr->hash != (hash_val) || !EQUAL((table), (key), (ptr)->key)))
#ifdef HASH_LOG
#define COLLISION collision++
#else
#define COLLISION
#endif
#define FIND_ENTRY(table, ptr, hash_val, bin_pos) do {\
bin_pos = hash_val%(table)->num_bins;\
ptr = (table)->bins[bin_pos];\
if (PTR_NOT_EQUAL(table, ptr, hash_val, key)) {\
COLLISION;\
while (PTR_NOT_EQUAL(table, ptr->next, hash_val, key)) {\
ptr = ptr->next;\
}\
ptr = ptr->next;\
}\
} while (0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment