Advertisement
polectron

Untitled

Dec 4th, 2016
155
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.03 KB | None | 0 0
  1. public double getLF(){
  2. double n = 0;
  3.  
  4. return n;
  5. }
  6.  
  7. public boolean add(T element){
  8. int attempNumber = 0;
  9. boolean success = false;
  10.  
  11. while(!success && attempNumber < ATTEMPS){
  12.  
  13. int slot = f(element, attempNumber);
  14.  
  15. if(associativeArray.get(slot).getStatus() != HashNode.VALID){
  16. success = true;
  17. associativeArray.get(slot).setStatus(HashNode.VALID);
  18. associativeArray.get(slot).setElement(element);
  19. return true;
  20. }else{
  21. attempNumber++;
  22. }
  23.  
  24. }
  25. return false;
  26.  
  27. }
  28.  
  29. public boolean search (T element){
  30. int attempNumber = 0;
  31. boolean success = false;
  32.  
  33. while(!success && attempNumber < ATTEMPS){
  34.  
  35. int slot = f(element, attempNumber);
  36.  
  37. if(associativeArray.get(slot).getStatus() == HashNode.EMPTY){
  38. return false;
  39. }
  40.  
  41. if(associativeArray.get(slot).getStatus() == HashNode.VALID && associativeArray.get(slot).getElement().equals(element)){
  42. return true;
  43. }else{
  44. attempNumber++;
  45. }
  46.  
  47. }
  48.  
  49. return false;
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement