Subversion Repositories programming

Rev

Rev 12 | Rev 14 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

// Written by Ira Snyder
// 10-18-2004
import java.io.*;
/////////////////////////////////////////////////////////////////////////////
class TestHashTable {
//---------------------------------------------------------------------------
    public static void main ( String [] args ) throws Exception {
        
        String[] names = {"Linear Probing","Prime Probing p=3",
                          "Prime Probing p=5","Prime Probing p=7",
                          "Prime Probing p=11","Quadratic Probing",
                          "Double Hashing" };
        
        for( int i=0; i < 7; i++ ) {
        
            System.out.println("Using Method: " + names[i]);
            System.out.println();
        
            HashTable testTable = new HashTable( 17 ); //set max size to 17
            testTable.setProbeType(i); //set the probe type

            testTable.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));

            System.out.println();
            System.out.println("Number of collisions: " + testTable.collisions());
        
            System.out.println();
            System.out.println("----------------------------------------");
            System.out.println();
        }
    
    }
//---------------------------------------------------------------------------
}
/////////////////////////////////////////////////////////////////////////////
/*
      BufferedReader kb = new BufferedReader(
                              new InputStreamReader(System.in));


      BufferedReader br = new BufferedReader(
                              new InputStreamReader(
                                  new FileInputStream(filename)));

      PrintStream ps = new PrintStream(
                           new FileOutputStream(
                               new File(filename)));

*/