private int[] ensureCapacity(int index) {

      int newlength = data.length;
      if (newlength == 0) {
        newlength = 1;
      }

      while (newlength <= index) {
        newlength *= 2;
      }

      data = Arrays.copyOf(data, newlength);
      next = Arrays.copyOf(next, newlength);

      return data;
    }
private int[] ensureCapacity(int index)