/**
   * Concat arrays in one.
   *
   * @param arrays Arrays.
   * @return Summary array.
   */
  public static int[] concat(int[]... arrays) {
    assert arrays != null;
    assert arrays.length > 1;

    int len = 0;

    for (int[] a : arrays) len += a.length;

    int[] r = Arrays.copyOf(arrays[0], len);

    for (int i = 1, shift = 0; i < arrays.length; i++) {
      shift += arrays[i - 1].length;
      System.arraycopy(arrays[i], 0, r, shift, arrays[i].length);
    }

    return r;
  }
示例#2
0
  /**
   * Sets given values starting at {@code 0} position.
   *
   * @param v Values to set.
   */
  public void set(Object... v) {
    A.ensure(v.length <= vals.length, "v.length <= vals.length");

    if (v.length > 0) System.arraycopy(v, 0, vals, 0, v.length);
  }
示例#3
0
  /**
   * Sets given values starting at provided position in the tuple.
   *
   * @param pos Position to start from.
   * @param v Values to set.
   */
  public void set(int pos, Object... v) {
    A.ensure(pos > 0, "pos > 0");
    A.ensure(v.length + pos <= vals.length, "v.length + pos <= vals.length");

    if (v.length > 0) System.arraycopy(v, 0, vals, pos, v.length);
  }