Ejemplo n.º 1
0
  public Index clone() {
    try {
      Index clone = (Index) super.clone();
      clone.table = this.table.clone();

      Entry list[], table[][] = clone.table;
      for (int cc = 0, len = this.size; cc < len; cc++) {
        list = table[cc];
        if (null != list) table[cc] = list.clone();
      }
      return clone;
    } catch (CloneNotSupportedException exc) {
      throw new InternalError(exc.toString());
    }
  }
Ejemplo n.º 2
0
 public static final void main(String[] test) {
   final String alphabet = "abcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
   Index index = new Index(20);
   for (int cc = 0; cc < 62; cc++) {
     Character key = new Character(alphabet.charAt(cc));
     index.add(key, cc);
   }
   index.distribution(false, System.out);
   int failure = 0;
   for (int cc = 0; cc < 62; cc++) {
     Character key = new Character(alphabet.charAt(cc));
     int idx = index.get(key);
     if (-1 == idx) {
       failure++;
       System.out.println("Test failed for key '" + key + "'.");
     }
   }
   if (0 == failure) System.out.println("Test passed.");
   System.exit(failure);
 }