Hi..im supposed to create a method that removes entries using linear probing but I cant seem to get it right.
Any pointers?
public static void entryRemover(HashMap<Integer, String> map) {
int max = Collections.max(map.entrySet(), Map.Entry.comparingByValue()).getKey();
int key = 0;
while(key <= max) {
if(map.containsKey(key)) {
map.remove(key);
}
if(!map.containsKey(key)) {
key = (key + 1) % map.size();
}
System.out.println(key);
}
System.out.print("new map size:" + map.size());
}
https://www.geeksforgeeks.org/java-program-to-implement-hashtables-with-linear-probing/