Advertisement
Guest User

Untitled

a guest
Oct 25th, 2014
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.08 KB | None | 0 0
  1. Integer temp = new Integer(0);
  2. for (int k = 0; k < 200; ++k) { // this function creates 200 unique strings and
  3. s = (new Integer(k)).toString(); // inserts them into the hash table
  4. h.insert("R"+s+"C"+s);
  5. }
  6.  
  7. boolean fail = false;
  8. for (int k = 0; k < 200; ++k) { // this function tries to find each string that
  9. s = (new Integer(k)).toString(); // was inserted into the hash table
  10. if (!h.find("R"+s+"C"+s) ) {
  11. fail = true;
  12. }
  13. }
  14.  
  15. public boolean find(String key) {
  16.  
  17. String stringKey = key;
  18. int hashToFind;
  19.  
  20. StringHashCode sH = new StringHashCode(arraySize);
  21.  
  22. hashToFind = sH.giveCode(stringKey);
  23.  
  24. if ( HashTable[hashToFind] == stringKey) { // this is where the method checks whether
  25. // or not the place in the hash table matches
  26. // the string we're trying to find
  27.  
  28. System.out.println(stringKey + " was found in index " + hashToFind);
  29. return true;
  30.  
  31. } else {
  32.  
  33. return findDoubleHash(hashToFind, key);
  34.  
  35. }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement