public class ArrayUtil extends Object
| Constructor and Description |
|---|
ArrayUtil() |
| Modifier and Type | Method and Description |
|---|---|
static double |
average(double[] values)
Get the average of an array of values.
|
static Object[] |
combine(Object[] a1,
Object[] a2)
Combine two arrays into a single, larger array.
|
static void |
dumpArray(PrintStream out,
Object[] array) |
static boolean |
equals(Object[] a1,
Object[] a2)
Array equality
|
static boolean |
exists(Object[] array,
Object element)
Return a boolean whether or not the element exists in the array
|
static int |
find(Object[] array,
Object element)
Find the index of the first appearance of an object in the array
|
static int |
findMinDiff(double[] values)
Find the 2 values with the smallest difference between them.
|
static boolean |
isUniq(String[] values)
Check to see if a _sorted_ array of values contains all unique values.
|
static int |
max(double[] values)
Find the maximum value in an array of double values.
|
static int |
max(int[] values)
Find the maximum value in an array of int values.
|
static Object[] |
merge(Object[][] arrays,
Object[] arrType) |
static Object[] |
merge(Object[] one,
Object[] two,
Object[] arrType) |
static int |
min(double[] values)
Find the minimum value in an array of double values.
|
static int[] |
stringToInt(String[] array)
Convert a string array to an array of int.
|
static Integer[] |
stringToInteger(String[] array)
Convert a string array to an array of Integer.
|
static double[] |
uniq(double[] values)
Return an array of values where every value is unique.
|
public static void dumpArray(PrintStream out, Object[] array)
public static int max(double[] values)
values - Values to search for to find the max ofpublic static int max(int[] values)
values - Values to search for to find the max ofpublic static int min(double[] values)
values - Values to search for to find the min ofpublic static double average(double[] values)
public static double[] uniq(double[] values)
values - Values to get the unique of. Note that this array _must_ be sorted, prior to invoking this methodpublic static boolean isUniq(String[] values)
public static boolean equals(Object[] a1, Object[] a2)
public static int findMinDiff(double[] values)
values - An array of _sorted_, _unique_ valuespublic static boolean exists(Object[] array, Object element)
array - An array of objectselement - The element to look for in the arraypublic static int find(Object[] array, Object element)
public static Integer[] stringToInteger(String[] array)
array is null, null will be returned.array - string arrayNumberFormatException - if an element in the String array is not parseable into an Integerpublic static int[] stringToInt(String[] array)
array is null, null will be returned.array - string arrayNumberFormatException - if an element in the String array is not parseable into an intpublic static Object[] combine(Object[] a1, Object[] a2)
a1 - The first array. If this is null, a copy of the second array is returned (unless it's null too, then
null is returned).a2 - The second array. If this is null, a copy of the first array is returned (unless it's null too, then
null is returned).Copyright © 2008-2013 Red Hat, Inc.. All Rights Reserved.