/* Closed (open addressing) hash map as a non-abstract class, using Object.hashCode. The reason we implemented CHMap as an abstract class was to make the hash function abstract. In fact, the Object superclass in Java already implements a int hashCode(); function, which classes such as String overrides. You can also override this function in your own class. We did not use this function to motivate different kinds of hash functions, and to show when an abstract class might be needed. We could have avoided writing an abstract class. But having our own hash function is still useful for customizing our implementation. The .hashCode() function may not return a value within range (% capacity) and, in fact, it may return a negative value. The following is a non-abstract version of our close hash table implementation: */ public class HMap extends CHMap { public HMap(int cap) { super(cap); } protected HMap makemap(int cap) { return new HMap(cap); } @SuppressWarnings("unchecked") protected KT[] makeKarray(int n) { return (KT[]) new Object[n]; } @SuppressWarnings("unchecked") protected VT[] makeVarray(int n) { return (VT[]) new Object[n]; } protected int hash(KT key) { return Math.abs(key.hashCode()) % Keys.length; } }//HMap // HMap M = new HMap(10);