Advertisement
Guest User

Untitled

a guest
Dec 19th, 2014
156
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. template <class T>
  2. void CHashTable<T>::grow()
  3. {
  4. Size = 0;
  5. vector<T> newtable(table.size() * 2, "0");
  6. for (int i = 0; i < table.size(); i++)
  7. {
  8. if (table[i] != "0" && table[i] != "DEL")
  9. {
  10. int fHash = Hash1(table[i], newtable.size());
  11. int sHash = Hash2(table[i], newtable.size());
  12.  
  13. while (newtable[fHash] != "0")
  14. {
  15. fHash = (fHash + sHash) % newtable.size();
  16. }
  17.  
  18. newtable[fHash] = table[i];
  19. Size++;
  20. }
  21. }
  22. table = newtable;
  23. for (int i = 0; table.size(); i++)
  24. {
  25. cout << " " << table[i] << " ";
  26. }
  27. cout << endl;
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement