java.util.Arrays.checkStartAndEnd()方法的使用及代码示例

x33g5p2x  于2022-01-15 转载在 其他  
字(11.8k)|赞(0)|评价(0)|浏览(106)

本文整理了Java中java.util.Arrays.checkStartAndEnd()方法的一些代码示例,展示了Arrays.checkStartAndEnd()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Arrays.checkStartAndEnd()方法的具体详情如下:
包路径:java.util.Arrays
类名称:Arrays
方法名:checkStartAndEnd

Arrays.checkStartAndEnd介绍

[英]Checks that the range described by start and end doesn't exceed len.
[中]检查“开始”和“结束”所描述的范围是否不超过len。

代码示例

代码示例来源:origin: robovm/robovm

/**
 * Fills the specified range in the array with the specified element.
 *
 * @param array
 *            the {@code byte} array to fill.
 * @param start
 *            the first index to fill.
 * @param end
 *            the last + 1 index to fill.
 * @param value
 *            the {@code byte} element.
 * @throws IllegalArgumentException
 *                if {@code start > end}.
 * @throws ArrayIndexOutOfBoundsException
 *                if {@code start < 0} or {@code end > array.length}.
 */
public static void fill(byte[] array, int start, int end, byte value) {
  Arrays.checkStartAndEnd(array.length, start, end);
  for (int i = start; i < end; i++) {
    array[i] = value;
  }
}

代码示例来源:origin: robovm/robovm

/**
 * Fills the specified range in the array with the specified element.
 *
 * @param array
 *            the {@code long} array to fill.
 * @param start
 *            the first index to fill.
 * @param end
 *            the last + 1 index to fill.
 * @param value
 *            the {@code long} element.
 * @throws IllegalArgumentException
 *                if {@code start > end}.
 * @throws ArrayIndexOutOfBoundsException
 *                if {@code start < 0} or {@code end > array.length}.
 */
public static void fill(long[] array, int start, int end, long value) {
  Arrays.checkStartAndEnd(array.length, start, end);
  for (int i = start; i < end; i++) {
    array[i] = value;
  }
}

代码示例来源:origin: robovm/robovm

/**
 * Fills the specified range in the array with the specified element.
 *
 * @param array
 *            the {@code short} array to fill.
 * @param start
 *            the first index to fill.
 * @param end
 *            the last + 1 index to fill.
 * @param value
 *            the {@code short} element.
 * @throws IllegalArgumentException
 *                if {@code start > end}.
 * @throws ArrayIndexOutOfBoundsException
 *                if {@code start < 0} or {@code end > array.length}.
 */
public static void fill(short[] array, int start, int end, short value) {
  Arrays.checkStartAndEnd(array.length, start, end);
  for (int i = start; i < end; i++) {
    array[i] = value;
  }
}

代码示例来源:origin: robovm/robovm

/**
 * Fills the specified range in the array with the specified element.
 *
 * @param array
 *            the {@code float} array to fill.
 * @param start
 *            the first index to fill.
 * @param end
 *            the last + 1 index to fill.
 * @param value
 *            the {@code float} element.
 * @throws IllegalArgumentException
 *                if {@code start > end}.
 * @throws ArrayIndexOutOfBoundsException
 *                if {@code start < 0} or {@code end > array.length}.
 */
public static void fill(float[] array, int start, int end, float value) {
  Arrays.checkStartAndEnd(array.length, start, end);
  for (int i = start; i < end; i++) {
    array[i] = value;
  }
}

代码示例来源:origin: robovm/robovm

/**
 * Fills the specified range in the array with the specified element.
 *
 * @param array
 *            the {@code Object} array to fill.
 * @param start
 *            the first index to fill.
 * @param end
 *            the last + 1 index to fill.
 * @param value
 *            the {@code Object} element.
 * @throws IllegalArgumentException
 *                if {@code start > end}.
 * @throws ArrayIndexOutOfBoundsException
 *                if {@code start < 0} or {@code end > array.length}.
 */
public static void fill(Object[] array, int start, int end, Object value) {
  Arrays.checkStartAndEnd(array.length, start, end);
  for (int i = start; i < end; i++) {
    array[i] = value;
  }
}

代码示例来源:origin: robovm/robovm

/**
 * Fills the specified range in the array with the specified element.
 *
 * @param array
 *            the {@code int} array to fill.
 * @param start
 *            the first index to fill.
 * @param end
 *            the last + 1 index to fill.
 * @param value
 *            the {@code int} element.
 * @throws IllegalArgumentException
 *                if {@code start > end}.
 * @throws ArrayIndexOutOfBoundsException
 *                if {@code start < 0} or {@code end > array.length}.
 */
public static void fill(int[] array, int start, int end, int value) {
  Arrays.checkStartAndEnd(array.length, start, end);
  for (int i = start; i < end; i++) {
    array[i] = value;
  }
}

代码示例来源:origin: robovm/robovm

/**
 * Fills the specified range in the array with the specified element.
 *
 * @param array
 *            the {@code double} array to fill.
 * @param start
 *            the first index to fill.
 * @param end
 *            the last + 1 index to fill.
 * @param value
 *            the {@code double} element.
 * @throws IllegalArgumentException
 *                if {@code start > end}.
 * @throws ArrayIndexOutOfBoundsException
 *                if {@code start < 0} or {@code end > array.length}.
 */
public static void fill(double[] array, int start, int end, double value) {
  Arrays.checkStartAndEnd(array.length, start, end);
  for (int i = start; i < end; i++) {
    array[i] = value;
  }
}

代码示例来源:origin: robovm/robovm

/**
 * Fills the specified range in the array with the specified element.
 *
 * @param array
 *            the {@code char} array to fill.
 * @param start
 *            the first index to fill.
 * @param end
 *            the last + 1 index to fill.
 * @param value
 *            the {@code char} element.
 * @throws IllegalArgumentException
 *                if {@code start > end}.
 * @throws ArrayIndexOutOfBoundsException
 *                if {@code start < 0} or {@code end > array.length}.
 */
public static void fill(char[] array, int start, int end, char value) {
  Arrays.checkStartAndEnd(array.length, start, end);
  for (int i = start; i < end; i++) {
    array[i] = value;
  }
}

代码示例来源:origin: robovm/robovm

/**
 * Fills the specified range in the array with the specified element.
 *
 * @param array
 *            the {@code boolean} array to fill.
 * @param start
 *            the first index to fill.
 * @param end
 *            the last + 1 index to fill.
 * @param value
 *            the {@code boolean} element.
 * @throws IllegalArgumentException
 *                if {@code start > end}.
 * @throws ArrayIndexOutOfBoundsException
 *                if {@code start < 0} or {@code end > array.length}.
 */
public static void fill(boolean[] array, int start, int end, boolean value) {
  Arrays.checkStartAndEnd(array.length, start, end);
  for (int i = start; i < end; i++) {
    array[i] = value;
  }
}

代码示例来源:origin: robovm/robovm

/**
 * Sorts the specified range of the array into ascending order. The range
 * to be sorted extends from the index {@code fromIndex}, inclusive, to
 * the index {@code toIndex}, exclusive. If {@code fromIndex == toIndex},
 * the range to be sorted is empty (and the call is a no-op).
 *
 * @param a the array to be sorted
 * @param fromIndex the index of the first element, inclusive, to be sorted
 * @param toIndex the index of the last element, exclusive, to be sorted
 * @throws IllegalArgumentException if {@code fromIndex > toIndex}
 * @throws ArrayIndexOutOfBoundsException
 *     if {@code fromIndex < 0} or {@code toIndex > a.length}
 */
public static void sort(byte[] a, int fromIndex, int toIndex) {
  Arrays.checkStartAndEnd(a.length, fromIndex, toIndex);
  doSort(a, fromIndex, toIndex - 1);
}

代码示例来源:origin: robovm/robovm

/**
 * Sorts the specified range of the array into ascending order. The range
 * to be sorted extends from the index {@code fromIndex}, inclusive, to
 * the index {@code toIndex}, exclusive. If {@code fromIndex == toIndex},
 * the range to be sorted is empty (and the call is a no-op).
 *
 * @param a the array to be sorted
 * @param fromIndex the index of the first element, inclusive, to be sorted
 * @param toIndex the index of the last element, exclusive, to be sorted
 * @throws IllegalArgumentException if {@code fromIndex > toIndex}
 * @throws ArrayIndexOutOfBoundsException
 *     if {@code fromIndex < 0} or {@code toIndex > a.length}
 */
public static void sort(int[] a, int fromIndex, int toIndex) {
  Arrays.checkStartAndEnd(a.length, fromIndex, toIndex);
  doSort(a, fromIndex, toIndex - 1);
}

代码示例来源:origin: robovm/robovm

/**
 * Sorts the specified range of the array into ascending order. The range
 * to be sorted extends from the index {@code fromIndex}, inclusive, to
 * the index {@code toIndex}, exclusive. If {@code fromIndex == toIndex},
 * the range to be sorted is empty (and the call is a no-op).
 *
 * @param a the array to be sorted
 * @param fromIndex the index of the first element, inclusive, to be sorted
 * @param toIndex the index of the last element, exclusive, to be sorted
 * @throws IllegalArgumentException if {@code fromIndex > toIndex}
 * @throws ArrayIndexOutOfBoundsException
 *     if {@code fromIndex < 0} or {@code toIndex > a.length}
 */
public static void sort(long[] a, int fromIndex, int toIndex) {
  Arrays.checkStartAndEnd(a.length, fromIndex, toIndex);
  doSort(a, fromIndex, toIndex - 1);
}

代码示例来源:origin: robovm/robovm

/**
 * Sorts the specified range of the array into ascending order. The range
 * to be sorted extends from the index {@code fromIndex}, inclusive, to
 * the index {@code toIndex}, exclusive. If {@code fromIndex == toIndex},
 * the range to be sorted is empty (and the call is a no-op).
 *
 * @param a the array to be sorted
 * @param fromIndex the index of the first element, inclusive, to be sorted
 * @param toIndex the index of the last element, exclusive, to be sorted
 * @throws IllegalArgumentException if {@code fromIndex > toIndex}
 * @throws ArrayIndexOutOfBoundsException
 *     if {@code fromIndex < 0} or {@code toIndex > a.length}
 */
public static void sort(short[] a, int fromIndex, int toIndex) {
  Arrays.checkStartAndEnd(a.length, fromIndex, toIndex);
  doSort(a, fromIndex, toIndex - 1);
}

代码示例来源:origin: robovm/robovm

/**
 * Sorts the specified range of the array into ascending order. The range
 * to be sorted extends from the index {@code fromIndex}, inclusive, to
 * the index {@code toIndex}, exclusive. If {@code fromIndex == toIndex},
 * the range to be sorted is empty (and the call is a no-op).
 *
 * @param a the array to be sorted
 * @param fromIndex the index of the first element, inclusive, to be sorted
 * @param toIndex the index of the last element, exclusive, to be sorted
 * @throws IllegalArgumentException if {@code fromIndex > toIndex}
 * @throws ArrayIndexOutOfBoundsException
 *     if {@code fromIndex < 0} or {@code toIndex > a.length}
 */
public static void sort(char[] a, int fromIndex, int toIndex) {
  Arrays.checkStartAndEnd(a.length, fromIndex, toIndex);
  doSort(a, fromIndex, toIndex - 1);
}

代码示例来源:origin: robovm/robovm

/**
 * Sorts the specified range of the array into ascending order. The range
 * to be sorted extends from the index {@code fromIndex}, inclusive, to
 * the index {@code toIndex}, exclusive. If {@code fromIndex == toIndex},
 * the range to be sorted is empty  and the call is a no-op).
 *
 * <p>The {@code <} relation does not provide a total order on all float
 * values: {@code -0.0f == 0.0f} is {@code true} and a {@code Float.NaN}
 * value compares neither less than, greater than, nor equal to any value,
 * even itself. This method uses the total order imposed by the method
 * {@link Float#compareTo}: {@code -0.0f} is treated as less than value
 * {@code 0.0f} and {@code Float.NaN} is considered greater than any
 * other value and all {@code Float.NaN} values are considered equal.
 *
 * @param a the array to be sorted
 * @param fromIndex the index of the first element, inclusive, to be sorted
 * @param toIndex the index of the last element, exclusive, to be sorted
 * @throws IllegalArgumentException if {@code fromIndex > toIndex}
 * @throws ArrayIndexOutOfBoundsException
 *     if {@code fromIndex < 0} or {@code toIndex > a.length}
 */
public static void sort(float[] a, int fromIndex, int toIndex) {
  Arrays.checkStartAndEnd(a.length, fromIndex, toIndex);
  sortNegZeroAndNaN(a, fromIndex, toIndex - 1);
}

代码示例来源:origin: robovm/robovm

/**
 * Sorts the specified range of the array into ascending order. The range
 * to be sorted extends from the index {@code fromIndex}, inclusive, to
 * the index {@code toIndex}, exclusive. If {@code fromIndex == toIndex},
 * the range to be sorted is empty (and the call is a no-op).
 *
 * <p>The {@code <} relation does not provide a total order on all double
 * values: {@code -0.0d == 0.0d} is {@code true} and a {@code Double.NaN}
 * value compares neither less than, greater than, nor equal to any value,
 * even itself. This method uses the total order imposed by the method
 * {@link Double#compareTo}: {@code -0.0d} is treated as less than value
 * {@code 0.0d} and {@code Double.NaN} is considered greater than any
 * other value and all {@code Double.NaN} values are considered equal.
 *
 * @param a the array to be sorted
 * @param fromIndex the index of the first element, inclusive, to be sorted
 * @param toIndex the index of the last element, exclusive, to be sorted
 * @throws IllegalArgumentException if {@code fromIndex > toIndex}
 * @throws ArrayIndexOutOfBoundsException
 *     if {@code fromIndex < 0} or {@code toIndex > a.length}
 */
public static void sort(double[] a, int fromIndex, int toIndex) {
  Arrays.checkStartAndEnd(a.length, fromIndex, toIndex);
  sortNegZeroAndNaN(a, fromIndex, toIndex - 1);
}

代码示例来源:origin: robovm/robovm

Arrays.checkStartAndEnd(a.length, lo, hi);
int nRemaining  = hi - lo;
if (nRemaining < 2)

代码示例来源:origin: robovm/robovm

static void sort(Object[] a, int lo, int hi) {
  Arrays.checkStartAndEnd(a.length, lo, hi);
  int nRemaining  = hi - lo;
  if (nRemaining < 2)

代码示例来源:origin: com.jtransc/jtransc-rt

@HaxeMethodBody(value = "p0.fill(p1, p2, p3);")
@JTranscMethodBody(target = "cpp", value = "GET_OBJECT(JA_C, p0)->fill(p1, p2, p3);")
public static void fill(char[] array, int start, int end, char value) {
  Arrays.checkStartAndEnd(array.length, start, end);
  for (int i = start; i < end; i++) {
    array[i] = value;
  }
}

代码示例来源:origin: com.jtransc/jtransc-rt

@HaxeMethodBody(value = "p0.fill(p1, p2, p3);")
@JTranscMethodBody(target = "cpp", value = "GET_OBJECT(JA_D, p0)->fill(p1, p2, p3);")
public static void fill(double[] array, int start, int end, double value) {
  Arrays.checkStartAndEnd(array.length, start, end);
  for (int i = start; i < end; i++) {
    array[i] = value;
  }
}

相关文章