Example #1
0
  public void insere(int x) {

    Node aux = new Node();

    aux.info = x;

    if (h[fht(x)] == null || x < h[fht(x)].info) {
      aux.prox = h[fht(x)];
      h[fht(x)] = aux;
    } else {
      Node aux2 = h[fht(x)];
      while ((aux2.prox != null) && (aux2.prox.info < x)) {
        aux2 = aux2.prox;
      }
      aux.prox = aux2.prox;
      aux2.prox = aux;
    }
  }
Example #2
0
 public int Remove(int x) {
   Node aux2 = h[fht(x)];
   if (aux2.info == x) {
     h[fht(x)] = aux2.prox;
   } else {
     while (aux2.prox != null) {
       if ((aux2.prox.info == x) && (aux2.prox != null)) {
         aux2.prox = aux2.prox.prox;
         break;
       }
       if (aux2.prox == null) {
         aux2 = null;
         break;
       }
       aux2 = aux2.prox;
     }
   }
   return x;
 }