Line 4... |
Line 4... |
4 |
/////////////////////////////////////////////////////////////////////////////
|
4 |
/////////////////////////////////////////////////////////////////////////////
|
5 |
class TestHashTable {
|
5 |
class TestHashTable {
|
6 |
//---------------------------------------------------------------------------
|
6 |
//---------------------------------------------------------------------------
|
7 |
public static void main ( String [] args ) throws Exception {
|
7 |
public static void main ( String [] args ) throws Exception {
|
8 |
|
8 |
|
- |
|
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 |
|
9 |
}
|
44 |
}
|
10 |
//---------------------------------------------------------------------------
|
45 |
//---------------------------------------------------------------------------
|
11 |
}
|
46 |
}
|
12 |
/////////////////////////////////////////////////////////////////////////////
|
47 |
/////////////////////////////////////////////////////////////////////////////
|
13 |
/*
|
48 |
/*
|