Esempio n. 1
0
 /**
  * Fills a portion of the given big array with the given value.
  *
  * <p>If possible (i.e., <code>from</code> is 0) this method uses a backward loop. In this case,
  * it is significantly faster than the corresponding method in {@link java.util.Arrays}.
  *
  * @param array a big array.
  * @param from the starting index of the portion to fill.
  * @param to the end index of the portion to fill.
  * @param value the new value for all elements of the specified portion of the big array.
  */
 public static void fill(final boolean[][] array, final long from, long to, final boolean value) {
   final long length = length(array);
   BigArrays.ensureFromTo(length, from, to);
   int fromSegment = segment(from);
   int toSegment = segment(to);
   int fromDispl = displacement(from);
   int toDispl = displacement(to);
   if (fromSegment == toSegment) {
     BooleanArrays.fill(array[fromSegment], fromDispl, toDispl, value);
     return;
   }
   if (toDispl != 0) BooleanArrays.fill(array[toSegment], 0, toDispl, value);
   while (--toSegment > fromSegment) BooleanArrays.fill(array[toSegment], value);
   BooleanArrays.fill(array[fromSegment], fromDispl, SEGMENT_SIZE, value);
 }
Esempio n. 2
0
 /**
  * Ensures that a range given by an offset and a length fits a big array.
  *
  * <p>This method may be used whenever a big array range check is needed.
  *
  * @param a a big 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 big array length.
  */
 public static void ensureOffsetLength(final boolean[][] a, final long offset, final long length) {
   BigArrays.ensureOffsetLength(length(a), offset, length);
 }
Esempio n. 3
0
 /**
  * Ensures that a range given by its first (inclusive) and last (exclusive) elements fits a big
  * array.
  *
  * <p>This method may be used whenever a big array range check is needed.
  *
  * @param a a big 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 big array length or negative.
  */
 public static void ensureFromTo(final boolean[][] a, final long from, final long to) {
   BigArrays.ensureFromTo(length(a), from, to);
 }