it.unimi.dsi.fastutil
Class Arrays

java.lang.Object
  extended byit.unimi.dsi.fastutil.Arrays

public class Arrays
extends Object

A class providing static methods and objects that do useful things with arrays.

See Also:
Arrays

Method Summary
static void ensureFromTo(int arrayLength, int from, int to)
          Ensures that a range given by its first (inclusive) and last (exclusive) elements fits an array of given length.
static void ensureOffsetLength(int arrayLength, int offset, int length)
          Ensures that a range given by an offset and a length fits an array of given length.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

ensureFromTo

public static void ensureFromTo(int arrayLength,
                                int from,
                                int to)
Ensures that a range given by its first (inclusive) and last (exclusive) elements fits an array of given length.

This method may be used whenever an array range check is needed.

Parameters:
arrayLength - an array length.
from - a start index (inclusive).
to - an end index (inclusive).
Throws:
IllegalArgumentException - if from is greater than to.
ArrayIndexOutOfBoundsException - if from or to are greater than arrayLength or negative.

ensureOffsetLength

public static void ensureOffsetLength(int arrayLength,
                                      int offset,
                                      int length)
Ensures that a range given by an offset and a length fits an array of given length.

This method may be used whenever an array range check is needed.

Parameters:
arrayLength - an array length.
offset - a start index for the fragment
length - a length (the number of elements in the fragment).
Throws:
IllegalArgumentException - if length is negative.
ArrayIndexOutOfBoundsException - if offset is negative or offset+length is greater than arrayLength.