public int nextIndex(int weight){
  if (used == parent.length) {
    int nsize=used + (used >> 1);
    this.weight=Arrays.copyOf(this.weight,nsize);
    this.parent=Arrays.copyOf(this.parent,nsize);
  }
  this.weight[used]=weight;
  this.parent[used]=used;
  return used++;
}

public int nextIndex ( int weight ) { if ( used == parent . length ) { int nsize = used + ( used > > 1 ) ; this . weight = Arrays . copyOf ( this . weight , nsize ) ; this . parent = Arrays . copyOf ( this . parent , nsize ) ; } this . weight [ used ] = weight ; this . parent [ used ] = used ; return used ++ ; }
occupy the next unused index .
