From: Godmar Back (gback@marker.cs.utah.edu)
Date: Sun Dec 13 1998 - 12:36:26 EST
You don't replace keys if you see free or removed slots first.
import java.util.*;
public class hash {
private static class O {
public int hashCode() {
return 5;
}
}
public static void main(String av[]) {
Hashtable h = new Hashtable();
O o1 = new O();
O o2 = new O();
h.put(o1, "A");
h.put(o2, "B");
h.remove(o1);
h.put(o2, "B");
int n = 0;
for (Enumeration e = h.keys(); e.hasMoreElements(); n++) {
e.nextElement();
}
if (n == 1)
System.out.println("PASS");
else
System.out.println("FAIL --- " + n);
}
}
This archive was generated by hypermail 2b29 : Sat Sep 23 2000 - 19:57:14 EDT