src/org/kocakosm/pitaya/util/XArrays.java
public static <T> T[] rotate(T[] a, int distance)
	{
		int len = a.length;
		T[] copy = newArray(a.getClass().getComponentType(), len);
		for (int i = 0; i < len; i++) {
			copy[i] = a[index(i - distance, len)];
		}
		return copy;
	}
public static <T> T[] rotate(T[] a, int distance)
	{
		int len = a.length;
		T[] copy = newArray(a.getClass().getComponentType(), len);
		for (int i = 0; i < len; i++) {
			copy[i] = a[index(i - distance, len)];
		}
		return copy;
	}
public static < T > T [ ] rotate ( T [ ] a , int distance ) { int len = a . length ; T [ ] copy = newArray ( a . getClass ( ) . getComponentType ( ) , len ) ; for ( int i = 0 ; i < len ; i ++ ) { copy [ i ] = a [ index ( i - distance , len ) ] ; } return copy ; }
Returns a new array containing the same elements as the given one,
but rotated by the given distance. The element at index {@code i} in
the returned array corresponds to the element in the original array
at index {@code (i - distance)} mod {@code a.length}, for all values
of {@code i} between {@code 0} and {@code a.length - 1}, inclusive.
Note that rotation by {@code 0} or by a multiple of {@code a.length}
is a no-op.

@param <T> the type of the elements in the array to rotate.
@param a the array to rotate.
@param distance the distance to rotate.

@return the rotated array.

@throws NullPointerException if {@code a} is {@code null}.
Returns a new array containing the same elements as the given one but rotated by the given distance . The element at index { @code i } in the returned array corresponds to the element in the original array at index { @code ( i - distance ) } mod { @code a . length } for all values of { @code i } between { @code 0 } and { @code a . length - 1 } inclusive . Note that rotation by { @code 0 } or by a multiple of { @code a . length } is a no - op .