Advertisement
Guest User

Untitled

a guest
Dec 16th, 2017
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.49 KB | None | 0 0
  1. void insertElement(HashTable* htable, const Key key, const Value value)
  2. {
  3. int hashedIndex = hash(key, getSize(htable)), i = 1;
  4.  
  5. while (htable->table[hashedIndex].key != UNUSED) {
  6. hashedIndex = hash(key + i, getSize(htable));
  7. i++;
  8. }
  9.  
  10. htable->table[hashedIndex].key = key;
  11. htable->table[hashedIndex].value = value;
  12.  
  13. // Postcondition: det finns ett element for key i tabellen (anvand lookup() for att verifiera)
  14. assert(lookup(htable, key)->personalNumber == value.personalNumber);
  15.  
  16. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement