12 |
irasnyd |
1 |
// Written by Ira Snyder
|
|
|
2 |
// 10-18-2004
|
|
|
3 |
import java.io.*;
|
|
|
4 |
/////////////////////////////////////////////////////////////////////////////
|
|
|
5 |
class TestHashTable {
|
|
|
6 |
//---------------------------------------------------------------------------
|
|
|
7 |
public static void main ( String [] args ) throws Exception {
|
|
|
8 |
|
13 |
irasnyd |
9 |
String[] names = {"Linear Probing","Prime Probing p=3",
|
|
|
10 |
"Prime Probing p=5","Prime Probing p=7",
|
|
|
11 |
"Prime Probing p=11","Quadratic Probing",
|
|
|
12 |
"Double Hashing" };
|
|
|
13 |
|
|
|
14 |
for( int i=0; i < 7; i++ ) {
|
|
|
15 |
|
|
|
16 |
System.out.println("Using Method: " + names[i]);
|
|
|
17 |
System.out.println();
|
|
|
18 |
|
|
|
19 |
HashTable testTable = new HashTable( 17 ); //set max size to 17
|
|
|
20 |
testTable.setProbeType(i); //set the probe type
|
|
|
21 |
|
|
|
22 |
testTable.put("AT",new Country("Austria","German",32378,8139299));
|
|
|
23 |
testTable.put("BE",new Country("Belgium","Dutch",11800,10182034));
|
|
|
24 |
testTable.put("DE",new Country("Germany","German",137800,82087361));
|
|
|
25 |
testTable.put("DK",new Country("Denmark","Danish",16639,5356845));
|
|
|
26 |
testTable.put("ES",new Country("Spain","Spanish",194880,39167744));
|
|
|
27 |
testTable.put("FR",new Country("France","French",211200,58978172));
|
|
|
28 |
testTable.put("GB",new Country("United Kingdom","English",94500,59113439));
|
|
|
29 |
testTable.put("GR",new Country("Greece","Greek",50900,10707135));
|
|
|
30 |
testTable.put("IE",new Country("Ireland","English",27100,3632944));
|
|
|
31 |
testTable.put("IT",new Country("Italy","Italian",116300,56735130));
|
|
|
32 |
testTable.put("LU",new Country("Luxembourg","French",998,429080));
|
|
|
33 |
testTable.put("NL",new Country("Netherlands","Dutch",16033,15807641));
|
|
|
34 |
testTable.put("SE",new Country("Sweden","Swedish",173732,8911296));
|
|
|
35 |
|
|
|
36 |
System.out.println();
|
|
|
37 |
System.out.println("Number of collisions: " + testTable.collisions());
|
|
|
38 |
|
|
|
39 |
System.out.println();
|
|
|
40 |
System.out.println("----------------------------------------");
|
|
|
41 |
System.out.println();
|
|
|
42 |
}
|
|
|
43 |
|
12 |
irasnyd |
44 |
}
|
|
|
45 |
//---------------------------------------------------------------------------
|
|
|
46 |
}
|
|
|
47 |
/////////////////////////////////////////////////////////////////////////////
|
|
|
48 |
/*
|
|
|
49 |
BufferedReader kb = new BufferedReader(
|
|
|
50 |
new InputStreamReader(System.in));
|
|
|
51 |
|
|
|
52 |
|
|
|
53 |
BufferedReader br = new BufferedReader(
|
|
|
54 |
new InputStreamReader(
|
|
|
55 |
new FileInputStream(filename)));
|
|
|
56 |
|
|
|
57 |
PrintStream ps = new PrintStream(
|
|
|
58 |
new FileOutputStream(
|
|
|
59 |
new File(filename)));
|
|
|
60 |
|
|
|
61 |
*/
|