示例#1
0
  /** Sort the ratings. */
  private void sortRatings() {
    int[] invMap = new int[index];
    for (int i = index - 1; i >= 0; i--) {
      invMap[i] = i;
    }

    Arrays.quickSort(0, index, new SortComparator(), new SortSwapper(invMap));

    translationMap = new int[index];
    for (int i = 0; i < invMap.length; i++) {
      translationMap[invMap[i]] = i;
    }
  }
示例#2
0
 /**
  * Ensures that a range given by an offset and a length fits an array.
  *
  * <p>This method may be used whenever an array range check is needed.
  *
  * @param a an array.
  * @param offset a start index.
  * @param length a length (the number of elements in the range).
  * @throws IllegalArgumentException if <code>length</code> is negative.
  * @throws ArrayIndexOutOfBoundsException if <code>offset</code> is negative or <code>offset
  *     </code>+<code>length</code> is greater than the array length.
  */
 public static void ensureOffsetLength(final long[] a, final int offset, final int length) {
   Arrays.ensureOffsetLength(a.length, offset, length);
 }
示例#3
0
 /**
  * Ensures that a range given by its first (inclusive) and last (exclusive) elements fits an
  * array.
  *
  * <p>This method may be used whenever an array range check is needed.
  *
  * @param a an array.
  * @param from a start index (inclusive).
  * @param to an end index (inclusive).
  * @throws IllegalArgumentException if <code>from</code> is greater than <code>to</code>.
  * @throws ArrayIndexOutOfBoundsException if <code>from</code> or <code>to</code> are greater than
  *     the array length or negative.
  */
 public static void ensureFromTo(final long[] a, final int from, final int to) {
   Arrays.ensureFromTo(a.length, from, to);
 }