- java.lang.Object
-
- org.jgrapht.util.ArrayUtil
-
public class ArrayUtil extends java.lang.ObjectUtility class to simplify handling of arrays.
-
-
Constructor Summary
Constructors Modifier Constructor Description privateArrayUtil()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voidreverse(int[] arr, int from, int to)Reverses the order of the elements in the specified range within the given array.static <V> voidreverse(V[] arr, int from, int to)Reverses the order of the elements in the specified range within the given array.static <V> voidswap(V[] arr, int i, int j)Swaps the two elements at the specified indices in the given array.
-
-
-
Method Detail
-
reverse
public static final <V> void reverse(V[] arr, int from, int to)Reverses the order of the elements in the specified range within the given array.- Type Parameters:
V- the type of elements in the array- Parameters:
arr- the arrayfrom- the index of the first element (inclusive) inside the range to reverseto- the index of the last element (inclusive) inside the range to reverse
-
reverse
public static final void reverse(int[] arr, int from, int to)Reverses the order of the elements in the specified range within the given array.- Parameters:
arr- the arrayfrom- the index of the first element (inclusive) inside the range to reverseto- the index of the last element (inclusive) inside the range to reverse
-
swap
public static final <V> void swap(V[] arr, int i, int j)Swaps the two elements at the specified indices in the given array.- Type Parameters:
V- the type of elements in the array- Parameters:
arr- the arrayi- the index of the first elementj- the index of the second element
-
-