|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectch.javasoft.util.Arrays
public class Arrays
The Arrays class contains static helper methods arround arrays,
similar to Arrays, but adding missing stuff.
| Field Summary | |
|---|---|
static double[] |
EMPTY_DOUBLE
|
static float[] |
EMPTY_FLOAT
|
static int[] |
EMPTY_INT
|
static long[] |
EMPTY_LONG
|
static Object[] |
EMPTY_OBJECT
|
| Method Summary | ||
|---|---|---|
static
|
asSet(T... a)
Returns a modifiable LinkedHashSet containing the submitted
elements. |
|
static int |
binarySearch(int[] a,
int fromIndex,
int toIndex,
int key)
Searches a range of the specified array of ints for the specified value using the binary search algorithm. |
|
static int[] |
copyOf(int[] original,
int newLength)
Copies the specified array, truncating or padding with zeros (if necessary) so the copy has the specified length. |
|
static
|
copyOf(T[] original,
int newLength)
Copies the specified array, truncating or padding with nulls (if necessary) so the copy has the specified length. |
|
static
|
copyOf(U[] original,
int newLength,
Class<? extends T[]> newType)
Copies the specified array, truncating or padding with nulls (if necessary) so the copy has the specified length. |
|
static double[] |
copyOfRange(double[] original,
int from,
int to)
Copies the specified range of the specified array into a new array. |
|
static int[] |
copyOfRange(int[] original,
int from,
int to)
Copies the specified range of the specified array into a new array. |
|
static long[] |
copyOfRange(long[] original,
int from,
int to)
Copies the specified range of the specified array into a new array. |
|
static
|
copyOfRange(T[] original,
int from,
int to)
Copies the specified range of the specified array into a new array. |
|
static
|
copyOfRange(U[] original,
int from,
int to,
Class<? extends T[]> newType)
Copies the specified range of the specified array into a new array. |
|
static boolean[] |
merge(boolean[] arr,
boolean... others)
|
|
static byte[] |
merge(byte[] arr,
byte... others)
|
|
static char[] |
merge(char[] arr,
char... others)
|
|
static double[] |
merge(double[] arr,
double... others)
|
|
static float[] |
merge(float[] arr,
float... others)
|
|
static int[] |
merge(int[] arr,
int... others)
|
|
static long[] |
merge(long[] arr,
long... others)
|
|
static short[] |
merge(short[] arr,
short... others)
|
|
static
|
merge(T[] arr,
T... others)
|
|
static
|
newArray(Class<T> clazz,
int length)
|
|
static
|
newArray(T[] template,
int length)
|
|
static void |
printArray(double[] arr)
|
|
static void |
printArray(double[][] arr)
|
|
static void |
printArray(int[] arr)
|
|
static void |
printArray(int[][] arr)
|
|
static void |
printArray(PrintStream out,
double[] arr)
|
|
static void |
printArray(PrintStream out,
double[][] arr)
|
|
static void |
printArray(PrintStream out,
int[] arr)
|
|
static void |
printArray(PrintStream out,
int[][] arr)
|
|
static void |
swap(boolean[] arr,
int indexA,
int indexB)
|
|
static void |
swap(byte[] arr,
int indexA,
int indexB)
|
|
static void |
swap(char[] arr,
int indexA,
int indexB)
|
|
static void |
swap(double[] arr,
int indexA,
int indexB)
|
|
static void |
swap(float[] arr,
int indexA,
int indexB)
|
|
static void |
swap(int[] arr,
int indexA,
int indexB)
|
|
static void |
swap(long[] arr,
int indexA,
int indexB)
|
|
static void |
swap(Object[] arr,
int indexA,
int indexB)
|
|
static void |
swap(short[] arr,
int indexA,
int indexB)
|
|
static void |
swapCol(boolean[][] arr,
int colA,
int colB)
|
|
static void |
swapCol(byte[][] arr,
int colA,
int colB)
|
|
static void |
swapCol(char[][] arr,
int colA,
int colB)
|
|
static void |
swapCol(double[][] arr,
int colA,
int colB)
|
|
static void |
swapCol(float[][] arr,
int colA,
int colB)
|
|
static void |
swapCol(int[][] arr,
int colA,
int colB)
|
|
static void |
swapCol(long[][] arr,
int colA,
int colB)
|
|
static void |
swapCol(Object[][] arr,
int colA,
int colB)
|
|
static void |
swapCol(short[][] arr,
int colA,
int colB)
|
|
static void |
swapRow(boolean[][] arr,
int rowA,
int rowB)
|
|
static void |
swapRow(byte[][] arr,
int rowA,
int rowB)
|
|
static void |
swapRow(char[][] arr,
int rowA,
int rowB)
|
|
static void |
swapRow(double[][] arr,
int rowA,
int rowB)
|
|
static void |
swapRow(float[][] arr,
int rowA,
int rowB)
|
|
static void |
swapRow(int[][] arr,
int rowA,
int rowB)
|
|
static void |
swapRow(long[][] arr,
int rowA,
int rowB)
|
|
static void |
swapRow(Object[][] arr,
int rowA,
int rowB)
|
|
static void |
swapRow(short[][] arr,
int rowA,
int rowB)
|
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static Object[] EMPTY_OBJECT
public static long[] EMPTY_LONG
public static int[] EMPTY_INT
public static double[] EMPTY_DOUBLE
public static float[] EMPTY_FLOAT
| Method Detail |
|---|
public static <T> Set<T> asSet(T... a)
LinkedHashSet containing the submitted
elements. If the list is empty or null, an empty linked hash set is
returned. In any case, the returned set is modifiable.
T - the element typea - the element(s)
public static void swap(Object[] arr,
int indexA,
int indexB)
public static void swap(long[] arr,
int indexA,
int indexB)
public static void swap(int[] arr,
int indexA,
int indexB)
public static void swap(short[] arr,
int indexA,
int indexB)
public static void swap(byte[] arr,
int indexA,
int indexB)
public static void swap(char[] arr,
int indexA,
int indexB)
public static void swap(boolean[] arr,
int indexA,
int indexB)
public static void swap(double[] arr,
int indexA,
int indexB)
public static void swap(float[] arr,
int indexA,
int indexB)
public static void swapRow(Object[][] arr,
int rowA,
int rowB)
public static void swapRow(long[][] arr,
int rowA,
int rowB)
public static void swapRow(int[][] arr,
int rowA,
int rowB)
public static void swapRow(short[][] arr,
int rowA,
int rowB)
public static void swapRow(byte[][] arr,
int rowA,
int rowB)
public static void swapRow(char[][] arr,
int rowA,
int rowB)
public static void swapRow(boolean[][] arr,
int rowA,
int rowB)
public static void swapRow(double[][] arr,
int rowA,
int rowB)
public static void swapRow(float[][] arr,
int rowA,
int rowB)
public static void swapCol(Object[][] arr,
int colA,
int colB)
public static void swapCol(long[][] arr,
int colA,
int colB)
public static void swapCol(int[][] arr,
int colA,
int colB)
public static void swapCol(short[][] arr,
int colA,
int colB)
public static void swapCol(byte[][] arr,
int colA,
int colB)
public static void swapCol(char[][] arr,
int colA,
int colB)
public static void swapCol(boolean[][] arr,
int colA,
int colB)
public static void swapCol(double[][] arr,
int colA,
int colB)
public static void swapCol(float[][] arr,
int colA,
int colB)
public static <T> T[] newArray(T[] template,
int length)
public static <T> T[] newArray(Class<T> clazz,
int length)
public static <T> T[] merge(T[] arr,
T... others)
public static long[] merge(long[] arr,
long... others)
public static int[] merge(int[] arr,
int... others)
public static short[] merge(short[] arr,
short... others)
public static byte[] merge(byte[] arr,
byte... others)
public static char[] merge(char[] arr,
char... others)
public static boolean[] merge(boolean[] arr,
boolean... others)
public static double[] merge(double[] arr,
double... others)
public static float[] merge(float[] arr,
float... others)
public static void printArray(int[] arr)
public static void printArray(double[] arr)
public static void printArray(PrintStream out,
int[] arr)
public static void printArray(PrintStream out,
double[] arr)
public static void printArray(int[][] arr)
public static void printArray(double[][] arr)
public static void printArray(PrintStream out,
int[][] arr)
public static void printArray(PrintStream out,
double[][] arr)
public static <T> T[] copyOfRange(T[] original,
int from,
int to)
The resulting array is of exactly the same class as the original array.
original - the array from which a range is to be copiedfrom - the initial index of the range to be copied, inclusiveto - the final index of the range to be copied, exclusive.
(This index may lie outside the array.)
ArrayIndexOutOfBoundsException - if from < 0
or from > original.length
IllegalArgumentException - if from > to
NullPointerException - if original is null
public static <T,U> T[] copyOfRange(U[] original,
int from,
int to,
Class<? extends T[]> newType)
original - the array from which a range is to be copiedfrom - the initial index of the range to be copied, inclusiveto - the final index of the range to be copied, exclusive.
(This index may lie outside the array.)newType - the class of the copy to be returned
ArrayIndexOutOfBoundsException - if from < 0
or from > original.length
IllegalArgumentException - if from > to
NullPointerException - if original is null
ArrayStoreException - if an element copied from
original is not of a runtime type that can be stored in
an array of class newType.
public static double[] copyOfRange(double[] original,
int from,
int to)
original - the array from which a range is to be copiedfrom - the initial index of the range to be copied, inclusiveto - the final index of the range to be copied, exclusive.
(This index may lie outside the array.)
ArrayIndexOutOfBoundsException - if from < 0
or from > original.length
IllegalArgumentException - if from > to
NullPointerException - if original is null
public static long[] copyOfRange(long[] original,
int from,
int to)
original - the array from which a range is to be copiedfrom - the initial index of the range to be copied, inclusiveto - the final index of the range to be copied, exclusive.
(This index may lie outside the array.)
ArrayIndexOutOfBoundsException - if from < 0
or from > original.length
IllegalArgumentException - if from > to
NullPointerException - if original is null
public static int[] copyOfRange(int[] original,
int from,
int to)
original - the array from which a range is to be copiedfrom - the initial index of the range to be copied, inclusiveto - the final index of the range to be copied, exclusive.
(This index may lie outside the array.)
ArrayIndexOutOfBoundsException - if from < 0
or from > original.length()
IllegalArgumentException - if from > to
NullPointerException - if original is null
public static <T> T[] copyOf(T[] original,
int newLength)
original - the array to be copiednewLength - the length of the copy to be returned
NegativeArraySizeException - if newLength is negative
NullPointerException - if original is null
public static <T,U> T[] copyOf(U[] original,
int newLength,
Class<? extends T[]> newType)
original - the array to be copiednewLength - the length of the copy to be returnednewType - the class of the copy to be returned
NegativeArraySizeException - if newLength is negative
NullPointerException - if original is null
ArrayStoreException - if an element copied from
original is not of a runtime type that can be stored in
an array of class newType
public static int[] copyOf(int[] original,
int newLength)
original - the array to be copiednewLength - the length of the copy to be returned
NegativeArraySizeException - if newLength is negative
NullPointerException - if original is null
public static int binarySearch(int[] a,
int fromIndex,
int toIndex,
int key)
Arrays.sort(int[], int, int) method)
prior to making this call. If it
is not sorted, the results are undefined. If the range contains
multiple elements with the specified value, there is no guarantee which
one will be found.
a - the array to be searchedfromIndex - the index of the first element (inclusive) to be
searchedtoIndex - the index of the last element (exclusive) to be searchedkey - the value to be searched for
IllegalArgumentException - if fromIndex > toIndex
ArrayIndexOutOfBoundsException - if fromIndex < 0 or
toIndex > a.length
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||