import java.util.*; // for ArrayList, Collection, etc class student implements Comparable // generic boring class { public final String name; // used as "key" public final int id; protected double gpa; protected String major; // ... other boring stuff skipped public student(String n, int i) { name=n; id=i; gpa = ((int)(Math.random()*401))/100.0; major = "cs"; } public String toString() {return name+" has id "+id+" and gpa "+gpa; } public int compareTo(student s) { return id -s.id; } //default compare }//student public class shash { protected ArrayList[] H; protected int size; public int size() { return size; } public shash(int buckets) { H = new ArrayList[buckets]; // expect compiler warning } protected int hash(String key) { int ax = 0; // accumulator for(int i=0;i(); else if (H[hi].remove(s)) size--; // remove old record H[hi].add(s); size++; } protected student search(String key, boolean del) { student answer = null; if (key==null) return null; int hi = hash(key); for(student s:H[hi]) if (key.equals(getkey(s))) { answer = s; if (del) { H[hi].remove(s); size--; } return answer; //break; } return answer; } public student lookup(String key) { return search(key,false); } public student delete(String key) { return search(key,true); } public static void main(String[] av) { shash HT = new shash(1000); HT.insert(new student("mary",702123456)); HT.insert(new student("larz",701654321)); HT.insert(new student("narx",702111111)); HT.delete("larz"); System.out.println( HT.lookup("mary")); System.out.println( HT.lookup("narx")); System.out.println( HT.lookup("larz")); } }//shash