
import java.io.*;

import java.util.Hashtable;

// Programm simuliert die Suche nach mehreren
// Werten in einer Hastatble

public class Hashmap3 {

   private static void pause() {
    try {
      System.in.read();
    }
    catch (IOException e) {
    }
  }  // pause

  public static void run(){
    final int MAX = 100000;
    long t1, t2;

    Integer Key;
    Student s1, s2;
    int k;
    // Hashtabelle erzeugen
    // Anfangswert,  Faktor
    Hashtable array = new Hashtable(10000, 0.70f);
    // Einfügen der Daten
    for (int i = 0; i < MAX; i++) {
      k = (int) (  10000*Math.random() );
      s1 = new Student(k,"Müller"+(i+1));
      Key = new Integer(k);
      array.put(Key,s1);
    }

    t1 =  System.currentTimeMillis();
    // Suchen
    for (int i = 0; i < MAX; i++) {
      k = (int) (  10000*Math.random() );
      Key = new Integer(k);
      s2 = (Student) array.get( Key );
    }
    t2 =  System.currentTimeMillis();
    System.out.println("Zeit: "+(t2-t1) );

   // return 21;
  }

	public static void main(String[] args) {
   run();
   System.out.println("Habe Fertig");
   pause();
  } // main


}



class Student {
 public int Matrnr;
 public String Name;


 public Student(int Matrnr, String Name) {
   this.Matrnr = Matrnr;
   this.Name = Name;
 }

}
