// By Haw-ren Fang, TA of cmsc420-0401, Spring 2002 import java.io.*; import java.lang.*; import java.util.Hashtable; // Usage: HashTableDriver2 [input file] [size1] [size2] [size3] ... // The driver will read in a file that contains patch identifiers (or // simply, patches). A patch identifier is a string satisfying the // regular expression [a-z][a-z]{0,1}*. Each patch is terminated by a new // line. An example file is: // pq011001 2.3 2.4 2.5 3.3 3.4 3.5 4.3 4.4 4.5 6.6 6.4 6.5 // pr101101 2.3 2.4 2.5 3.3 3.4 3.5 4.3 4.4 4.5 6.6 6.4 6.5 // The items, (key, value) pairs, will be stored in the hashtable // The output will report probing counts (cost) of linear and double // hashing. You can get 10/10 points if the result shows your double // hashing is more efficient than linear probing. public class HashTableDriver2 { private static void printUsage() { System.out.println("Usage: HashTableDriver2 [input file] [size1] [size2] [size3] ..."); System.exit(1); } private static void putError(String key) { System.err.println("Error occurs while running HashTable.put() with key=" + key); System.err.println("Either your HashTable does not guarantee successful insert when there is an empty address available,"); System.err.println("Or your HashTable does not reject duplicate keys."); System.err.println("You get 0/10 points." ); System.exit(1); } public static void main(String args[]) throws Exception { if (args.length <= 1) printUsage(); String key, value; System.out.println("Double hashing test:"); try { for (int i=1; i