1: //HashTable.java (from zyDE 5.10.1) 3: // Abstract class for a hash table that supports the insert, remove, and search 4: // operations. 5: public abstract class HashTable 6: { 7: // Returns a non-negative hash code for the specified key. 8: protected int hash(Object key) 9: { 10: long keyHash = key.hashCode(); 12: // Java's hashCode() method may return a negative number 13: if (keyHash < 0) 14: { 15: keyHash += 2147483648L; 16: } 18: return (int)keyHash; 19: } 21: // Inserts the specified key/value pair. If the key already exists, the 22: // corresponding value is updated. If inserted or updated, true is returned. 23: // If not inserted, then false is returned. 24: public abstract boolean insert(Object key, Object value); 26: // Searches for the specified key. If found, the key/value pair is removed 27: // from the hash table and true is returned. If not found, false is returned. 28: public abstract boolean remove(Object key); 30: // Searches for the key, returning the corresponding value if found, null if 31: // not found. 32: public abstract Object search(Object key); 33: }