Ejemplo n.º 1
0
  public static void main(String[] args) {
    RangeHash rh = new RangeHash();
    System.err.println("apple = " + rh.put(12, 20, "Apple"));
    System.err.println("carrot = " + rh.put(41, 50, "Carrot"));
    System.err.println("doughnut = " + rh.put(59, 70, "Doughnut"));
    System.err.println("egg = " + rh.put(78, 79, "Egg"));
    System.err.println("banana = " + rh.put(23, 27, "Banana"));
    //	System.err.println("apricot = "+rh.put(14,50,"Apricot"));

    System.err.println("fish = " + rh.put(121, 160, "Fish"));

    System.err.println(
        "REMOVE OF (14,51) = " + rh.getInterval(41)[0] + "," + rh.getInterval(41)[1]);
    System.err.println();

    Enumeration e = rh.values();
    while (e.hasMoreElements()) System.err.println(e.nextElement());
    /*
    	System.err.println("duds:");
    	System.err.println("9 = "+rh.get(9));
    	System.err.println("21 = "+rh.get(21));
    	System.err.println();
    	System.err.println("good ones:");
    	System.err.println("20 = "+rh.get(20));
    	System.err.println("12 = "+rh.get(12));
    	System.err.println("41 = "+rh.get(41));
    	System.err.println("59 = "+rh.get(59));
    	System.err.println("78 = "+rh.get(78));
    	System.err.println("23 = "+rh.get(23));
    	System.err.println("121 = "+rh.get(121));
    	System.err.println();
    	System.err.println("63 = "+rh.get(63));
    	System.err.println("50 = "+rh.get(50));
    	System.err.println("129 = "+rh.get(129));
    	System.err.println("26 = "+rh.get(26));
    */

  }
Ejemplo n.º 2
0
 public int compare(Object a, Object b) {
   Range ah = (Range) a;
   Range bh = (Range) b;
   return RangeHash.compare(ah, bh);
 }