Rev 14 | Blame | Last modification | View Log | RSS feed
// Written by Ira Snyder// 10-18-2004import java.io.*;/////////////////////////////////////////////////////////////////////////////class TestHashTable {//---------------------------------------------------------------------------public static void main ( String [] args ) throws Exception {//set up an array holding the names of each probing method, for//easy retrieval in the main loopString[] names = {"Linear Probing","Prime Probing p=3","Prime Probing p=5","Prime Probing p=7","Prime Probing p=11","Quadratic Probing","Double Hashing" };HashTable testTable; //create the HashTable that we are going to use//run once for each probing methodfor( int i=0; i < 7; i++ ) {//print out the probe method we are usingSystem.out.println("Using Method: " + names[i]);System.out.println();//clear the HashTable and set the next probe typetestTable = new HashTable( 17 ); //set max size to 17testTable.setProbeType(i); //set the probe type//enter all the datatestTable.put("AT",new Country("Austria","German",32378,8139299));testTable.put("BE",new Country("Belgium","Dutch",11800,10182034));testTable.put("DE",new Country("Germany","German",137800,82087361));testTable.put("DK",new Country("Denmark","Danish",16639,5356845));testTable.put("ES",new Country("Spain","Spanish",194880,39167744));testTable.put("FR",new Country("France","French",211200,58978172));testTable.put("GB",new Country("United Kingdom","English",94500,59113439));testTable.put("GR",new Country("Greece","Greek",50900,10707135));testTable.put("IE",new Country("Ireland","English",27100,3632944));testTable.put("IT",new Country("Italy","Italian",116300,56735130));testTable.put("LU",new Country("Luxembourg","French",998,429080));testTable.put("NL",new Country("Netherlands","Dutch",16033,15807641));testTable.put("SE",new Country("Sweden","Swedish",173732,8911296));//print out the number of collisionsSystem.out.println();System.out.println("Number of collisions: " + testTable.collisions());//print a seperatorSystem.out.println();System.out.println("----------------------------------------");System.out.println();}}//---------------------------------------------------------------------------}/////////////////////////////////////////////////////////////////////////////