Class ArrayUtil
- java.lang.Object
-
- dev.brachtendorf.ArrayUtil
-
public class ArrayUtil extends Object
- Author:
- Kilian
-
-
Constructor Summary
Constructors Constructor Description ArrayUtil()
-
Method Summary
All Methods Static Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static voidadd(byte[] arr, byte summand)Add the supplied argument to every field in the arraystatic voidadd(char[] arr, char summand)Add the supplied argument to every field in the arraystatic voidadd(double[] arr, double summand)Add the supplied argument to every field in the arraystatic voidadd(float[] arr, float summand)Add the supplied argument to every field in the arraystatic voidadd(int[] arr, int summand)Add the supplied argument to every field in the arraystatic voidadd(long[] arr, long summand)Add the supplied argument to every field in the arraystatic voidadd(short[] arr, short summand)Add the supplied argument to every field in the arraystatic <T> booleanallNotNull(T[] array)Check if all values in the array are not nullstatic <T> booleanallNull(T[] array)Check if all values in the array are nullstatic doubleaverage(byte[] array)Calculates the average value of the array.static doubleaverage(byte[][] array)Calculates the average value of the 2d array.static doubleaverage(char[] array)Calculates the average value of the array.static doubleaverage(char[][] array)Calculates the average value of the 2d array.static doubleaverage(double[] array)Calculates the average value of the array.static doubleaverage(double[][] array)Calculates the average value of the 2d array.static doubleaverage(float[] array)Calculates the average value of the array.static doubleaverage(float[][] array)Calculates the average value of the 2d array.static doubleaverage(int[] array)Calculates the average value of the array.static doubleaverage(int[][] array)Calculates the average value of the 2d array.static doubleaverage(long[] array)Calculates the average value of the array.static doubleaverage(long[][] array)Calculates the average value of the 2d array.static doubleaverage(short[] array)Calculates the average value of the array.static doubleaverage(short[][] array)Calculates the average value of the 2d array.static booleandeepAllNotNull(Object[] array)Check if all values in the array are not null.static <T> T[]deepArrayCopy(T[] array)Deep copy nested arrays.static <T> T[]deepArrayCopyClone(T[] array)Deprecated.static StringdeepToString(Object[] array)Returns a string representation of the "deep contents" of the specified array.static StringdeepToStringFormatted(Object[] array)Returns a string representation of the "deep contents" of the specified array.static voiddivide(byte[] arrDividend, byte divisor)Calculate the quotient for each field in the arraystatic voiddivide(byte[] arrDivisor, byte[] dividend)Pairwise divide the two vectors.static voiddivide(char[] arrDividend, char divisor)Calculate the quotient for each field in the arraystatic voiddivide(char[] arrDivisor, char[] dividend)Pairwise divide the two vectors.static voiddivide(double[] arrDividend, double divisor)Calculate the quotient for each field in the arraystatic voiddivide(double[] arrDivisor, double[] dividend)Pairwise divide the two vectors.static voiddivide(float[] arrDividend, float divisor)Calculate the quotient for each field in the arraystatic voiddivide(float[] arrDivisor, float[] dividend)Pairwise divide the two vectors.static voiddivide(int[] arrDividend, int divisor)Calculate the quotient for each field in the arraystatic voiddivide(int[] arrDivisor, int[] dividend)Pairwise divide the two vectors.static voiddivide(long[] arrDividend, long divisor)Calculate the quotient for each field in the arraystatic voiddivide(long[] arrDivisor, long[] dividend)Pairwise divide the two vectors.static voiddivide(short[] arrDividend, short divisor)Calculate the quotient for each field in the arraystatic voiddivide(short[] arrDivisor, short[] dividend)Pairwise divide the two vectors.static voidfillArray(boolean[] array, Function<Integer,Boolean> supplier)Fill the array with values returned by the supplierstatic voidfillArray(boolean[] array, Supplier<Boolean> s)Fill the entire array with the value returned by the supplier.static voidfillArray(byte[] array, Supplier<Byte> s)Fill the entire array with the value returned by the supplier.static voidfillArray(char[] array, Function<Integer,Character> supplier)Fill the array with values returned by the supplierstatic voidfillArray(char[] array, Supplier<Character> s)Fill the entire array with the value returned by the supplier.static voidfillArray(double[] array, Function<Integer,Double> supplier)Fill the array with values returned by the supplierstatic voidfillArray(double[] array, Supplier<Double> s)Fill the entire array with the value returned by the supplier.static voidfillArray(float[] array, Function<Integer,Float> supplier)Fill the array with values returned by the supplierstatic voidfillArray(float[] array, Supplier<Float> s)Fill the entire array with the value returned by the supplier.static voidfillArray(int[] array, Function<Integer,Integer> supplier)Fill the array with values returned by the supplierstatic voidfillArray(int[] array, Supplier<Integer> s)Fill the entire array with the value returned by the supplier.static voidfillArray(long[] array, Function<Integer,Long> supplier)Fill the array with values returned by the supplierstatic voidfillArray(long[] array, Supplier<Long> s)Fill the entire array with the value returned by the supplier.static voidfillArray(short[] array, Function<Integer,Short> supplier)Fill the array with values returned by the supplierstatic voidfillArray(short[] array, Supplier<Short> s)Fill the entire array with the value returned by the supplier.static <T> voidfillArray(T[] array, Function<Integer,T> supplier)Fill the array with values returned by the supplierstatic <T> voidfillArray(T[] array, Supplier<T> s)Fill the entire array with the value returned by the supplier.static <T> TfillArrayMulti(T array, Function<Integer,T> s)Fill a multi dimensional array with the value returned by the supplierstatic <T> TfillArrayMulti(T array, Supplier<T> s)Fill a multi dimensional array with the value returned by the supplierstatic <T> intfrontBackSearch(T[] array, T needle)Search the specified array for the specified value.static <T> intfrontBackSearch(T[] array, T needle, int from, int to)Search the specified array for the specified value.static <T> Tget(Object array, int... index)static int[]getSortedIndices(boolean[] array, boolean descending)Compute the sorted indices for the array.static int[]getSortedIndices(byte[] array, boolean descending)Compute the sorted indices for the array.static int[]getSortedIndices(char[] array, boolean descending)Compute the sorted indices for the array.static int[]getSortedIndices(double[] array, boolean descending)Compute the sorted indices for the array.static int[]getSortedIndices(float[] array, boolean descending)Compute the sorted indices for the array.static int[]getSortedIndices(int[] array, boolean descending)Compute the sorted indices for the array.static int[]getSortedIndices(long[] array, boolean descending)Compute the sorted indices for the array.static int[]getSortedIndices(short[] array, boolean descending)Compute the sorted indices for the array.static <T> intlinearSearch(T[] array, T needle)Search the specified array for the specified value.static <T> intlinearSearch(T[] array, T needle, int start, int stop)Search the specified array for the specified value.static bytemaximum(byte[] array)Find the maximum value of the arraystatic charmaximum(char[] array)Find the maximum value of the arraystatic doublemaximum(double[] array)Find the maximum value of the arraystatic floatmaximum(float[] array)Find the maximum value of the arraystatic intmaximum(int[] array)Find the maximum value of the arraystatic longmaximum(long[] array)Find the maximum value of the arraystatic shortmaximum(short[] array)Find the maximum value of the arraystatic intmaximumIndex(byte[] array)Find the index of the maximum value of the array.static intmaximumIndex(char[] array)Find the index of the maximum value of the array.static intmaximumIndex(double[] array)Find the index of the maximum value of the array.static intmaximumIndex(float[] array)Find the index of the maximum value of the array.static intmaximumIndex(int[] array)Find the index of the maximum value of the array.static intmaximumIndex(long[] array)Find the index of the maximum value of the array.static intmaximumIndex(short[] array)Find the index of the maximum value of the array.static doublemedian(byte[] array)Calculate the median value of the arraystatic doublemedian(char[] array)Calculate the median value of the arraystatic doublemedian(double[] array)Calculate the median value of the arraystatic doublemedian(float[] array)Calculate the median value of the arraystatic doublemedian(int[] array)Calculate the median value of the arraystatic doublemedian(long[] array)Calculate the median value of the arraystatic doublemedian(short[] array)Calculate the median value of the arraystatic byteminimum(byte[] array)Find the minimum value of the arraystatic charminimum(char[] array)Find the minimum value of the arraystatic doubleminimum(double[] array)Find the minimum value of the arraystatic floatminimum(float[] array)Find the minimum value of the arraystatic intminimum(int[] array)Find the minimum value of the arraystatic longminimum(long[] array)Find the minimum value of the arraystatic shortminimum(short[] array)Find the minimum value of the arraystatic intminimumIndex(byte[] array)Find the index of the minimum value of the array.static intminimumIndex(char[] array)Find the index of the minimum value of the array.static intminimumIndex(double[] array)Find the index of the minimum value of the array.static intminimumIndex(float[] array)Find the index of the minimum value of the array.static intminimumIndex(int[] array)Find the index of the minimum value of the array.static intminimumIndex(long[] array)Find the index of the minimum value of the array.static intminimumIndex(short[] array)Find the index of the minimum value of the array.static voidmultiply(byte[] arr, byte factor)Scalar Multiplication.static voidmultiply(byte[] arr, byte[] factors)Pairwise multiply the two vectors.static voidmultiply(char[] arr, char factor)Scalar Multiplication.static voidmultiply(char[] arr, char[] factors)Pairwise multiply the two vectors.static voidmultiply(double[] arr, double factor)Scalar Multiplication.static voidmultiply(double[] arr, double[] factors)Pairwise multiply the two vectors.static voidmultiply(float[] arr, float factor)Scalar Multiplication.static voidmultiply(float[] arr, float[] factors)Pairwise multiply the two vectors.static voidmultiply(int[] arr, int factor)Scalar Multiplication.static voidmultiply(int[] arr, int[] factors)Pairwise multiply the two vectors.static voidmultiply(long[] arr, long factor)Scalar Multiplication.static voidmultiply(long[] arr, long[] factors)Pairwise multiply the two vectors.static voidmultiply(short[] arr, short factor)Scalar Multiplication.static voidmultiply(short[] arr, short[] factors)Pairwise multiply the two vectors.static voidsubtract(byte[] arrMinuend, byte subtrahend)Calculate the difference for each field in the arraystatic voidsubtract(char[] arrMinuend, char subtrahend)Calculate the difference for each field in the arraystatic voidsubtract(double[] arrMinuend, double subtrahend)Calculate the difference for each field in the arraystatic voidsubtract(float[] arrMinuend, float subtrahend)Calculate the difference for each field in the arraystatic voidsubtract(int[] arrMinuend, int subtrahend)Calculate the difference for each field in the arraystatic voidsubtract(long[] arrMinuend, long subtrahend)Calculate the difference for each field in the arraystatic voidsubtract(short[] arrMinuend, short subtrahend)Calculate the difference for each field in the arraystatic StringtoString(double[] array, int decimalPlaces)Return the string representation of an array containing floating point numbers with fixed decimal places.The string representation consists of a list of the array's elements,enclosed in square brackets ("[]").static StringtoString(float[] array, int decimalPlaces)Return the string representation of an array containing floating point numbers with fixed decimal places.static StringtoString(Object[] array)Returns a string representation of the contents of the specified array.If the array contains other arrays as elements, they are converted to strings by the Object.toString method inherited from Object, which describes their identities rather than their contents.static inttwoDimtoOneDim(int x, int y, int width)Map 2 dimensional coordinates to a one dimensional array
-
-
-
Method Detail
-
toString
public static String toString(double[] array, int decimalPlaces)
Return the string representation of an array containing floating point numbers with fixed decimal places.The string representation consists of a list of the array's elements,enclosed in square brackets ("[]"). Adjacent elements are separated by the characters ", " (a comma followed by a space). Elements are converted to strings as by String.valueOf(double). Returns "null" if a is null.- Parameters:
array- The array content to convert to a stringdecimalPlaces- the number of fractional numbers shown for each entry- Returns:
- a string representation of the double array
- Since:
- 1.0.0 com.github.kilianB
-
toString
public static String toString(float[] array, int decimalPlaces)
Return the string representation of an array containing floating point numbers with fixed decimal places. The string representation consists of a list of the array's elements,enclosed in square brackets ("[]"). Adjacent elements are separated by the characters ", " (a comma followed by a space). Elements are converted to strings as by String.valueOf(float). Returns "null" if a is null.- Parameters:
array- The array content to convert to a stringdecimalPlaces- the number of fractional numbers shown for each entry- Returns:
- a string representation of the float array
- Since:
- 1.0.0 com.github.kilianB
-
deepToStringFormatted
public static String deepToStringFormatted(Object[] array)
Returns a string representation of the "deep contents" of the specified array. If the array contains other arrays as elements, the string representation contains their contents and so on. This method is designed for converting multidimensional arrays to strings.A linebreak is introduced after every array useful to visualize 2d datastructures.
- Parameters:
array- the array whose string representation to return- Returns:
- a formatted string representation of the array
- Since:
- 1.5.0 com.github.kilianB
-
deepToString
public static String deepToString(Object[] array)
Returns a string representation of the "deep contents" of the specified array. If the array contains other arrays as elements, the string representation contains their contents and so on. This method is designed for converting multidimensional arrays to strings.- Parameters:
array- the array whose string representation to return- Returns:
- a formatted string representation of the array
- Since:
- 1.5.0 com.github.kilianB
-
toString
public static String toString(Object[] array)
Returns a string representation of the contents of the specified array.If the array contains other arrays as elements, they are converted to strings by the Object.toString method inherited from Object, which describes their identities rather than their contents.- Parameters:
array- the array whose string representation to return- Returns:
- a string representation of the array
- Since:
- 1.5.0 com.github.kilianB
-
deepArrayCopy
public static <T> T[] deepArrayCopy(T[] array)
Deep copy nested arrays. A shallow copy of each array contained in this array will be created allowing to alter the values without affecting the original data structure. Be aware that the individual components are only copied and still point to the same object.If a true deep clone is required take a look at
deepArrayCopyClone(Object[])instead.- Type Parameters:
T- the type of the array- Parameters:
array- The array to clone- Returns:
- an new array with all nested arrays being replaced by copies.
- Since:
- 1.0.0 com.github.kilianB
-
deepArrayCopyClone
@Deprecated public static <T> T[] deepArrayCopyClone(T[] array) throws Exception
Deprecated.Deep copies the array structures as well as attempts to callObject.clone()if the element implements the the cloneable interface. Even if cloneable is implemented no guarantee is made that the returned element is in fact a deep clone of the base object. The class specific clone implementation has to be looked at individually. Untested- Type Parameters:
T- the type of the array- Parameters:
array- The array to clone- Returns:
- a truly deep cloned array
- Throws:
Exception- if an exception occurs during cloning of individual objects- Since:
- 1.0.0 com.github.kilianB
-
deepAllNotNull
public static boolean deepAllNotNull(Object[] array)
Check if all values in the array are not null. This operation supports nested arrays- Parameters:
array- to check- Returns:
- true if all elements in the array are not null
- Since:
- 1.0.0 com.github.kilianB
-
allNotNull
public static <T> boolean allNotNull(T[] array)
Check if all values in the array are not null- Type Parameters:
T- the type of the array- Parameters:
array- to check- Returns:
- true if all elements in the array are not null
- Since:
- 1.0.0 com.github.kilianB
-
allNull
public static <T> boolean allNull(T[] array)
Check if all values in the array are null- Type Parameters:
T- the type of the array- Parameters:
array- to check- Returns:
- true if all elements in the array are null
- Since:
- 1.0.0 com.github.kilianB
-
twoDimtoOneDim
public static int twoDimtoOneDim(int x, int y, int width)Map 2 dimensional coordinates to a one dimensional array- Parameters:
x- The first coordinatey- The second coordinatewidth- the width of the 2 dim array- Returns:
- a mapped integer.
- Since:
- 1.0.0 com.github.kilianB
-
fillArray
public static <T> void fillArray(T[] array, Supplier<T> s)Fill the entire array with the value returned by the supplier.- Type Parameters:
T- The type of the array- Parameters:
array- The array to fills- The supplier used- Since:
- 1.0.0 com.github.kilianB
-
fillArrayMulti
public static <T> T fillArrayMulti(T array, Supplier<T> s)Fill a multi dimensional array with the value returned by the supplier- Type Parameters:
T- the type of the array- Parameters:
array- The array to fills- The supplier- Returns:
- the supplied array. The return value is used to allow recursive behavior of the method and can safely be ignored by the user. The original supplied array is identical to the returned reference. If the supplied array is not an array null will be returned.
- Since:
- 1.2.0 com.github.kilianB
-
fillArrayMulti
public static <T> T fillArrayMulti(T array, Function<Integer,T> s)Fill a multi dimensional array with the value returned by the supplier- Type Parameters:
T- the type of the array- Parameters:
array- The array to fills- The supplier taking the index of the current array as argument- Returns:
- the supplied array. The return value is used to allow recursive behavior of the method and can safely be ignored by the user. The original supplied array is identical to the returned reference. If the supplied array is not an array null will be returned.
- Since:
- 1.2.0 com.github.kilianB
-
fillArray
public static void fillArray(boolean[] array, Supplier<Boolean> s)Fill the entire array with the value returned by the supplier.- Parameters:
array- The array to fills- The supplier used- Since:
- 1.0.0 com.github.kilianB
-
fillArray
public static void fillArray(byte[] array, Supplier<Byte> s)Fill the entire array with the value returned by the supplier.- Parameters:
array- The array to fills- The supplier used- Since:
- 1.0.0 com.github.kilianB
-
fillArray
public static void fillArray(char[] array, Supplier<Character> s)Fill the entire array with the value returned by the supplier.- Parameters:
array- The array to fills- The supplier used- Since:
- 1.0.0 com.github.kilianB
-
fillArray
public static void fillArray(short[] array, Supplier<Short> s)Fill the entire array with the value returned by the supplier.- Parameters:
array- The array to fills- The supplier used- Since:
- 1.0.0 com.github.kilianB
-
fillArray
public static void fillArray(int[] array, Supplier<Integer> s)Fill the entire array with the value returned by the supplier.- Parameters:
array- The array to fills- The supplier used- Since:
- 1.0.0 com.github.kilianB
-
fillArray
public static void fillArray(long[] array, Supplier<Long> s)Fill the entire array with the value returned by the supplier.- Parameters:
array- The array to fills- The supplier used- Since:
- 1.0.0 com.github.kilianB
-
fillArray
public static void fillArray(float[] array, Supplier<Float> s)Fill the entire array with the value returned by the supplier.- Parameters:
array- The array to fills- The supplier used- Since:
- 1.0.0 com.github.kilianB
-
fillArray
public static void fillArray(double[] array, Supplier<Double> s)Fill the entire array with the value returned by the supplier.- Parameters:
array- The array to fills- The supplier used- Since:
- 1.0.0 com.github.kilianB
-
fillArray
public static void fillArray(boolean[] array, Function<Integer,Boolean> supplier)Fill the array with values returned by the supplier- Parameters:
array- the array to fillsupplier- A function returning a value whose argument takes the index of the array- Since:
- 1.4.4 com.github.kilianB
-
fillArray
public static void fillArray(char[] array, Function<Integer,Character> supplier)Fill the array with values returned by the supplier- Parameters:
array- the array to fillsupplier- A function returning a value whose argument takes the index of the array- Since:
- 1.4.4 com.github.kilianB
-
fillArray
public static void fillArray(short[] array, Function<Integer,Short> supplier)Fill the array with values returned by the supplier- Parameters:
array- the array to fillsupplier- A function returning a value whose argument takes the index of the array- Since:
- 1.4.4 com.github.kilianB
-
fillArray
public static void fillArray(int[] array, Function<Integer,Integer> supplier)Fill the array with values returned by the supplier- Parameters:
array- the array to fillsupplier- A function returning a value whose argument takes the index of the array- Since:
- 1.4.4 com.github.kilianB
-
fillArray
public static void fillArray(long[] array, Function<Integer,Long> supplier)Fill the array with values returned by the supplier- Parameters:
array- the array to fillsupplier- A function returning a value whose argument takes the index of the array- Since:
- 1.4.4 com.github.kilianB
-
fillArray
public static void fillArray(float[] array, Function<Integer,Float> supplier)Fill the array with values returned by the supplier- Parameters:
array- the array to fillsupplier- A function returning a value whose argument takes the index of the array- Since:
- 1.4.4 com.github.kilianB
-
fillArray
public static void fillArray(double[] array, Function<Integer,Double> supplier)Fill the array with values returned by the supplier- Parameters:
array- the array to fillsupplier- A function returning a value whose argument takes the index of the array- Since:
- 1.4.4 com.github.kilianB
-
fillArray
public static <T> void fillArray(T[] array, Function<Integer,T> supplier)Fill the array with values returned by the supplier- Type Parameters:
T- the type of the array- Parameters:
array- the array to fillsupplier- A function returning a value whose argument takes the index of the array- Since:
- 1.4.4 com.github.kilianB
-
linearSearch
public static <T> int linearSearch(T[] array, T needle, int start, int stop)Search the specified array for the specified value. This operation works on unsorted array but has a O(N) worst case time complexity. For efficient searching considerArrays.binarySearch(long[], long).If the same array gets searched consistently you may also consider creating a hash index to bring down the search to O(1).
- Type Parameters:
T- the type of the array- Parameters:
array- the array to be searchedneedle- the value to search forstart- the index position to start searching fromstop- the last index position to stop search at- Returns:
- the index position of the value if found or -1 if not present
- Since:
- 1.0.0 com.github.kilianB
-
linearSearch
public static <T> int linearSearch(T[] array, T needle)Search the specified array for the specified value. This operation works on unsorted array but has a O(N) worst case time complexity. For efficient searching considerArrays.binarySearch(long[], long).If the same array gets searched consistently you may also consider creating a hash index to bring down the search to O(1).
- Type Parameters:
T- the type of the array- Parameters:
array- the array to be searchedneedle- the value to search for- Returns:
- the index position of the value if found or -1 if not present
- Since:
- 1.0.0 com.github.kilianB
-
frontBackSearch
public static <T> int frontBackSearch(T[] array, T needle, int from, int to)Search the specified array for the specified value. This operation tries to minimize the number of comparisons. The array is search from the beginning and end simultaneously resulting in worst case performance if the searched value is exactly in the middle. For efficient searching considerArrays.binarySearch(long[], long).If the same array gets searched consistently you may also consider creating a hash index to bring down the search to O(1).
- Type Parameters:
T- the type of the array- Parameters:
array- the array to be searchedneedle- the value to search forfrom- the index position to start searching fromto- the last index positin to stop search at- Returns:
- the index position of the value if found or -1 if not present
- Throws:
ArrayIndexOutOfBoundsException- if from or two are outside of the array- Since:
- 1.0.0 com.github.kilianB
-
frontBackSearch
public static <T> int frontBackSearch(T[] array, T needle)Search the specified array for the specified value. This operation tries to minimize the number of comparisons. The array is search from the beginning and end simultaneously resulting in worst case performance if the searched value is exactly in the middle. For efficient searching considerArrays.binarySearch(long[], long).If the same array gets searched consistently you may also consider creating a hash index to bring down the search to O(1).
- Type Parameters:
T- the type of the array- Parameters:
array- the array to be searchedneedle- the value to search for- Returns:
- the index position of the value if found or -1 if not present
- Since:
- 1.0.0 com.github.kilianB
-
getSortedIndices
public static int[] getSortedIndices(boolean[] array, boolean descending)Compute the sorted indices for the array. The indices can be used to access the content of the array in sorted order. The first index of the returned array will either point to the highest or lowest value, the second index to the second highest/lowest ... found in the array.If duplicate values exist in the array no stability guarantee is made.
ImplNote: TODO: check the performance of this method. An additional class can be constructed holding index value pairs and sorting this omitting the creation of a map. In turn this would mean that a new class must be created for every primitive type. If this is considered to slow maybe even using optimized collections like Colt's int int hashmap might be suitable.
- Parameters:
array- the array to compute the sorted indexes fordescending- if true compute descending indices else ascending- Returns:
- an array containing sort indices
- Since:
- 1.4.4 com.github.kilianB
-
getSortedIndices
public static int[] getSortedIndices(byte[] array, boolean descending)Compute the sorted indices for the array. The indices can be used to access the content of the array in sorted order. The first index of the returned array will either point to the highest or lowest value, the second index to the second highest/lowest ... found in the array.If duplicate values exist in the array no stability guarantee is made.
ImplNote: TODO: check the performance of this method. An additional class can be constructed holding index value pairs and sorting this omitting the creation of a map. In turn this would mean that a new class must be created for every primitive type. If this is considered to slow maybe even using optimized collections like Colt's int int hashmap might be suitable.
- Parameters:
array- the array to compute the sorted indexes fordescending- if true compute descending indices else ascending- Returns:
- an array containing sort indices
- Since:
- 1.4.4 com.github.kilianB
-
getSortedIndices
public static int[] getSortedIndices(char[] array, boolean descending)Compute the sorted indices for the array. The indices can be used to access the content of the array in sorted order. The first index of the returned array will either point to the highest or lowest value, the second index to the second highest/lowest ... found in the array.If duplicate values exist in the array no stability guarantee is made.
ImplNote: TODO: check the performance of this method. An additional class can be constructed holding index value pairs and sorting this omitting the creation of a map. In turn this would mean that a new class must be created for every primitive type. If this is considered to slow maybe even using optimized collections like Colt's int int hashmap might be suitable.
- Parameters:
array- the array to compute the sorted indexes fordescending- if true compute descending indices else ascending- Returns:
- an array containing sort indices
- Since:
- 1.4.4 com.github.kilianB
-
getSortedIndices
public static int[] getSortedIndices(short[] array, boolean descending)Compute the sorted indices for the array. The indices can be used to access the content of the array in sorted order. The first index of the returned array will either point to the highest or lowest value, the second index to the second highest/lowest ... found in the array.If duplicate values exist in the array no stability guarantee is made.
ImplNote: TODO: check the performance of this method. An additional class can be constructed holding index value pairs and sorting this omitting the creation of a map. In turn this would mean that a new class must be created for every primitive type. If this is considered to slow maybe even using optimized collections like Colt's int int hashmap might be suitable.
- Parameters:
array- the array to compute the sorted indexes fordescending- if true compute descending indices else ascending- Returns:
- an array containing sort indices
- Since:
- 1.4.4 com.github.kilianB
-
getSortedIndices
public static int[] getSortedIndices(int[] array, boolean descending)Compute the sorted indices for the array. The indices can be used to access the content of the array in sorted order. The first index of the returned array will either point to the highest or lowest value, the second index to the second highest/lowest ... found in the array.If duplicate values exist in the array no stability guarantee is made.
ImplNote: TODO: check the performance of this method. An additional class can be constructed holding index value pairs and sorting this omitting the creation of a map. In turn this would mean that a new class must be created for every primitive type. If this is considered to slow maybe even using optimized collections like Colt's int int hashmap might be suitable.
- Parameters:
array- the array to compute the sorted indexes fordescending- if true compute descending indices else ascending- Returns:
- an array containing sort indices
- Since:
- 1.4.4 com.github.kilianB
-
getSortedIndices
public static int[] getSortedIndices(long[] array, boolean descending)Compute the sorted indices for the array. The indices can be used to access the content of the array in sorted order. The first index of the returned array will either point to the highest or lowest value, the second index to the second highest/lowest ... found in the array.If duplicate values exist in the array no stability guarantee is made.
ImplNote: TODO: check the performance of this method. An additional class can be constructed holding index value pairs and sorting this omitting the creation of a map. In turn this would mean that a new class must be created for every primitive type. If this is considered to slow maybe even using optimized collections like Colt's int int hashmap might be suitable.
- Parameters:
array- the array to compute the sorted indexes fordescending- if true compute descending indices else ascending- Returns:
- an array containing sort indices
- Since:
- 1.4.4 com.github.kilianB
-
getSortedIndices
public static int[] getSortedIndices(float[] array, boolean descending)Compute the sorted indices for the array. The indices can be used to access the content of the array in sorted order. The first index of the returned array will either point to the highest or lowest value, the second index to the second highest/lowest ... found in the array.If duplicate values exist in the array no stability guarantee is made.
ImplNote: TODO: check the performance of this method. An additional class can be constructed holding index value pairs and sorting this omitting the creation of a map. In turn this would mean that a new class must be created for every primitive type. If this is considered to slow maybe even using optimized collections like Colt's int int hashmap might be suitable.
- Parameters:
array- the array to compute the sorted indexes fordescending- if true compute descending indices else ascending- Returns:
- an array containing sort indices
- Since:
- 1.4.4 com.github.kilianB
-
getSortedIndices
public static int[] getSortedIndices(double[] array, boolean descending)Compute the sorted indices for the array. The indices can be used to access the content of the array in sorted order. The first index of the returned array will either point to the highest or lowest value, the second index to the second highest/lowest ... found in the array.If duplicate values exist in the array no stability guarantee is made.
ImplNote: TODO: check the performance of this method. An additional class can be constructed holding index value pairs and sorting this omitting the creation of a map. In turn this would mean that a new class must be created for every primitive type. If this is considered to slow maybe even using optimized collections like Colt's int int hashmap might be suitable.
- Parameters:
array- the array to compute the sorted indexes fordescending- if true compute descending indices else ascending- Returns:
- an array containing sort indices
- Since:
- 1.4.4 com.github.kilianB
-
minimumIndex
public static int minimumIndex(byte[] array)
Find the index of the minimum value of the array.If the minimum value is present multiple times the first occurrence will be returned.
- Parameters:
array- the array to check- Returns:
- the index of the minimum value of the array or -1 if the array is empty
- Throws:
NullPointerException- if the array is null- Since:
- 1.4.0 com.github.kilianB
-
minimumIndex
public static int minimumIndex(char[] array)
Find the index of the minimum value of the array.If the minimum value is present multiple times the first occurrence will be returned.
- Parameters:
array- the array to check- Returns:
- the index of the minimum value of the array or -1 if the array is empty
- Throws:
NullPointerException- if the array is null- Since:
- 1.4.0 com.github.kilianB
-
minimumIndex
public static int minimumIndex(short[] array)
Find the index of the minimum value of the array.If the minimum value is present multiple times the first occurrence will be returned.
- Parameters:
array- the array to check- Returns:
- the index of the minimum value of the array or -1 if the array is empty
- Throws:
NullPointerException- if the array is null- Since:
- 1.4.0 com.github.kilianB
-
minimumIndex
public static int minimumIndex(int[] array)
Find the index of the minimum value of the array.If the minimum value is present multiple times the first occurrence will be returned.
- Parameters:
array- the array to check- Returns:
- the index of the minimum value of the array or -1 if the array is empty
- Throws:
NullPointerException- if the array is null- Since:
- 1.4.0 com.github.kilianB
-
minimumIndex
public static int minimumIndex(long[] array)
Find the index of the minimum value of the array.If the minimum value is present multiple times the first occurrence will be returned.
- Parameters:
array- the array to check- Returns:
- the index of the minimum value of the array or -1 if the array is empty
- Throws:
NullPointerException- if the array is null- Since:
- 1.4.0 com.github.kilianB
-
minimumIndex
public static int minimumIndex(float[] array)
Find the index of the minimum value of the array.If the minimum value is present multiple times the first occurrence will be returned.
- Parameters:
array- the array to check- Returns:
- the index of the minimum value of the array or -1 if the array is empty
- Throws:
NullPointerException- if the array is null- Since:
- 1.4.0 com.github.kilianB
-
minimumIndex
public static int minimumIndex(double[] array)
Find the index of the minimum value of the array.If the minimum value is present multiple times the first occurrence will be returned.
- Parameters:
array- the array to check- Returns:
- the index of the minimum value of the array or -1 if the array is empty
- Throws:
NullPointerException- if the array is null- Since:
- 1.4.0 com.github.kilianB
-
minimum
public static byte minimum(byte[] array)
Find the minimum value of the array- Parameters:
array- the array to check- Returns:
- the minimum value of the array
- Throws:
IndexOutOfBoundsException- if the array is emptyNullPointerException- if the array is null- Since:
- 1.4.0 com.github.kilianB
-
minimum
public static char minimum(char[] array)
Find the minimum value of the array- Parameters:
array- the array to check- Returns:
- the minimum value of the array
- Throws:
IndexOutOfBoundsException- if the array is emptyNullPointerException- if the array is null- Since:
- 1.4.0 com.github.kilianB
-
minimum
public static short minimum(short[] array)
Find the minimum value of the array- Parameters:
array- the array to check- Returns:
- the minimum value of the array
- Throws:
IndexOutOfBoundsException- if the array is emptyNullPointerException- if the array is null- Since:
- 1.4.0 com.github.kilianB
-
minimum
public static int minimum(int[] array)
Find the minimum value of the array- Parameters:
array- the array to check- Returns:
- the minimum value of the array
- Throws:
IndexOutOfBoundsException- if the array is emptyNullPointerException- if the array is null- Since:
- 1.4.0 com.github.kilianB
-
minimum
public static long minimum(long[] array)
Find the minimum value of the array- Parameters:
array- the array to check- Returns:
- the minimum value of the array
- Throws:
IndexOutOfBoundsException- if the array is emptyNullPointerException- if the array is null- Since:
- 1.4.0 com.github.kilianB
-
minimum
public static float minimum(float[] array)
Find the minimum value of the array- Parameters:
array- the array to check- Returns:
- the minimum value of the array
- Throws:
IndexOutOfBoundsException- if the array is emptyNullPointerException- if the array is null- Since:
- 1.4.0 com.github.kilianB
-
minimum
public static double minimum(double[] array)
Find the minimum value of the array- Parameters:
array- the array to check- Returns:
- the minimum value of the array
- Throws:
IndexOutOfBoundsException- if the array is emptyNullPointerException- if the array is null- Since:
- 1.4.0 com.github.kilianB
-
maximumIndex
public static int maximumIndex(byte[] array)
Find the index of the maximum value of the array.If the maximum value is present multiple times the first occurrence will be returned.
- Parameters:
array- the array to check- Returns:
- the index of the maximum value of the array or -1 if the array is empty
- Throws:
NullPointerException- if the array is null- Since:
- 1.4.0 com.github.kilianB
-
maximumIndex
public static int maximumIndex(char[] array)
Find the index of the maximum value of the array.If the maximum value is present multiple times the first occurrence will be returned.
- Parameters:
array- the array to check- Returns:
- the index of the maximum value of the array or -1 if the array is empty
- Throws:
NullPointerException- if the array is null- Since:
- 1.4.0 com.github.kilianB
-
maximumIndex
public static int maximumIndex(short[] array)
Find the index of the maximum value of the array.If the maximum value is present multiple times the first occurrence will be returned.
- Parameters:
array- the array to check- Returns:
- the index of the maximum value of the array or -1 if the array is empty
- Throws:
NullPointerException- if the array is null- Since:
- 1.4.0 com.github.kilianB
-
maximumIndex
public static int maximumIndex(int[] array)
Find the index of the maximum value of the array.If the maximum value is present multiple times the first occurrence will be returned.
- Parameters:
array- the array to check- Returns:
- the index of the maximum value of the array or -1 if the array is empty
- Throws:
NullPointerException- if the array is null- Since:
- 1.4.0 com.github.kilianB
-
maximumIndex
public static int maximumIndex(long[] array)
Find the index of the maximum value of the array.If the maximum value is present multiple times the first occurrence will be returned.
- Parameters:
array- the array to check- Returns:
- the index of the maximum value of the array or -1 if the array is empty
- Throws:
NullPointerException- if the array is null- Since:
- 1.4.0 com.github.kilianB
-
maximumIndex
public static int maximumIndex(float[] array)
Find the index of the maximum value of the array.If the maximum value is present multiple times the first occurrence will be returned.
- Parameters:
array- the array to check- Returns:
- the index of the maximum value of the array or -1 if the array is empty
- Throws:
NullPointerException- if the array is null- Since:
- 1.4.0 com.github.kilianB
-
maximumIndex
public static int maximumIndex(double[] array)
Find the index of the maximum value of the array.If the maximum value is present multiple times the first occurrence will be returned.
- Parameters:
array- the array to check- Returns:
- the index of the maximum value of the array or -1 if the array is empty
- Throws:
NullPointerException- if the array is null- Since:
- 1.4.0 com.github.kilianB
-
maximum
public static byte maximum(byte[] array)
Find the maximum value of the array- Parameters:
array- the array to check- Returns:
- the maximum value of the array
- Throws:
IndexOutOfBoundsException- if the array is emptyNullPointerException- if the array is null- Since:
- 1.4.0 com.github.kilianB
-
maximum
public static char maximum(char[] array)
Find the maximum value of the array- Parameters:
array- the array to check- Returns:
- the maximum value of the array
- Throws:
IndexOutOfBoundsException- if the array is emptyNullPointerException- if the array is null- Since:
- 1.4.0 com.github.kilianB
-
maximum
public static short maximum(short[] array)
Find the maximum value of the array- Parameters:
array- the array to check- Returns:
- the maximum value of the array
- Throws:
IndexOutOfBoundsException- if the array is emptyNullPointerException- if the array is null- Since:
- 1.4.0 com.github.kilianB
-
maximum
public static int maximum(int[] array)
Find the maximum value of the array- Parameters:
array- the array to check- Returns:
- the maximum value of the array
- Throws:
IndexOutOfBoundsException- if the array is emptyNullPointerException- if the array is null- Since:
- 1.4.0 com.github.kilianB
-
maximum
public static long maximum(long[] array)
Find the maximum value of the array- Parameters:
array- the array to check- Returns:
- the maximum value of the array
- Throws:
IndexOutOfBoundsException- if the array is emptyNullPointerException- if the array is null- Since:
- 1.4.0 com.github.kilianB
-
maximum
public static float maximum(float[] array)
Find the maximum value of the array- Parameters:
array- the array to check- Returns:
- the maximum value of the array
- Throws:
IndexOutOfBoundsException- if the array is emptyNullPointerException- if the array is null- Since:
- 1.4.0 com.github.kilianB
-
maximum
public static double maximum(double[] array)
Find the maximum value of the array- Parameters:
array- the array to check- Returns:
- the maximum value of the array
- Throws:
IndexOutOfBoundsException- if the array is emptyNullPointerException- if the array is null- Since:
- 1.4.0 com.github.kilianB
-
add
public static void add(byte[] arr, byte summand)Add the supplied argument to every field in the array- Parameters:
arr- the array holding the first summandsummand- the value to add to each field- Since:
- 1.4.0 com.github.kilianB
-
add
public static void add(char[] arr, char summand)Add the supplied argument to every field in the array- Parameters:
arr- the array holding the first summandsummand- the value to add to each field- Since:
- 1.4.0 com.github.kilianB
-
add
public static void add(short[] arr, short summand)Add the supplied argument to every field in the array- Parameters:
arr- the array holding the first summandsummand- the value to add to each field- Since:
- 1.4.0 com.github.kilianB
-
add
public static void add(int[] arr, int summand)Add the supplied argument to every field in the array- Parameters:
arr- the array holding the first summandsummand- the value to add to each field- Since:
- 1.4.0 com.github.kilianB
-
add
public static void add(long[] arr, long summand)Add the supplied argument to every field in the array- Parameters:
arr- the array holding the first summandsummand- the value to add to each field- Since:
- 1.4.0 com.github.kilianB
-
add
public static void add(float[] arr, float summand)Add the supplied argument to every field in the array- Parameters:
arr- the array holding the first summandsummand- the value to add to each field- Since:
- 1.4.0 com.github.kilianB
-
add
public static void add(double[] arr, double summand)Add the supplied argument to every field in the array- Parameters:
arr- the array holding the first summandsummand- the value to add to each field- Since:
- 1.4.0 com.github.kilianB
-
subtract
public static void subtract(byte[] arrMinuend, byte subtrahend)Calculate the difference for each field in the array- Parameters:
arrMinuend- the array holding the minuendsubtrahend- the value to subtracted from each field- Since:
- 1.4.0 com.github.kilianB
-
subtract
public static void subtract(char[] arrMinuend, char subtrahend)Calculate the difference for each field in the array- Parameters:
arrMinuend- the array holding the minuendsubtrahend- the value to subtracted from each field- Since:
- 1.4.0 com.github.kilianB
-
subtract
public static void subtract(short[] arrMinuend, short subtrahend)Calculate the difference for each field in the array- Parameters:
arrMinuend- the array holding the minuendsubtrahend- the value to subtracted from each field- Since:
- 1.4.0 com.github.kilianB
-
subtract
public static void subtract(int[] arrMinuend, int subtrahend)Calculate the difference for each field in the array- Parameters:
arrMinuend- the array holding the minuendsubtrahend- the value to subtracted from each field- Since:
- 1.4.0 com.github.kilianB
-
subtract
public static void subtract(long[] arrMinuend, long subtrahend)Calculate the difference for each field in the array- Parameters:
arrMinuend- the array holding the minuendsubtrahend- the value to subtracted from each field- Since:
- 1.4.0 com.github.kilianB
-
subtract
public static void subtract(float[] arrMinuend, float subtrahend)Calculate the difference for each field in the array- Parameters:
arrMinuend- the array holding the minuendsubtrahend- the value to subtracted from each field- Since:
- 1.4.0 com.github.kilianB
-
subtract
public static void subtract(double[] arrMinuend, double subtrahend)Calculate the difference for each field in the array- Parameters:
arrMinuend- the array holding the minuendsubtrahend- the value to subtracted from each field- Since:
- 1.4.0 com.github.kilianB
-
multiply
public static void multiply(byte[] arr, byte factor)Scalar Multiplication. Calculate the product for each field in the array.- Parameters:
arr- the array holding the first factorfactor- the value to multiply each field by- Since:
- 1.4.0 com.github.kilianB
-
multiply
public static void multiply(char[] arr, char factor)Scalar Multiplication. Calculate the product for each field in the array- Parameters:
arr- the array holding the first factorfactor- the value to multiply each field by- Since:
- 1.4.0 com.github.kilianB
-
multiply
public static void multiply(short[] arr, short factor)Scalar Multiplication. Calculate the product for each field in the array- Parameters:
arr- the array holding the first factorfactor- the value to multiply each field by- Since:
- 1.4.0 com.github.kilianB
-
multiply
public static void multiply(int[] arr, int factor)Scalar Multiplication. Calculate the product for each field in the array- Parameters:
arr- the array holding the first factorfactor- the value to multiply each field by- Since:
- 1.4.0 com.github.kilianB
-
multiply
public static void multiply(long[] arr, long factor)Scalar Multiplication. Calculate the product for each field in the array- Parameters:
arr- the array holding the first factorfactor- the value to multiply each field by- Since:
- 1.4.0 com.github.kilianB
-
multiply
public static void multiply(float[] arr, float factor)Scalar Multiplication. Calculate the product for each field in the array- Parameters:
arr- the array holding the first factorfactor- the value to multiply each field by- Since:
- 1.4.0 com.github.kilianB
-
multiply
public static void multiply(double[] arr, double factor)Scalar Multiplication. Calculate the product for each field in the array- Parameters:
arr- the array holding the first factorfactor- the value to multiply each field by- Since:
- 1.4.0 com.github.kilianB
-
divide
public static void divide(byte[] arrDividend, byte divisor)Calculate the quotient for each field in the array- Parameters:
arrDividend- the array holding the dividenddivisor- the divisor each field is divided by- Since:
- 1.4.0 com.github.kilianB
-
divide
public static void divide(char[] arrDividend, char divisor)Calculate the quotient for each field in the array- Parameters:
arrDividend- the array holding the dividenddivisor- the divisor each field is divided by- Since:
- 1.4.0 com.github.kilianB
-
divide
public static void divide(short[] arrDividend, short divisor)Calculate the quotient for each field in the array- Parameters:
arrDividend- the array holding the dividenddivisor- the divisor each field is divided by- Since:
- 1.4.0 com.github.kilianB
-
divide
public static void divide(int[] arrDividend, int divisor)Calculate the quotient for each field in the array- Parameters:
arrDividend- the array holding the dividenddivisor- the divisor each field is divided by- Since:
- 1.4.0 com.github.kilianB
-
divide
public static void divide(long[] arrDividend, long divisor)Calculate the quotient for each field in the array- Parameters:
arrDividend- the array holding the dividenddivisor- the divisor each field is divided by- Since:
- 1.4.0 com.github.kilianB
-
divide
public static void divide(float[] arrDividend, float divisor)Calculate the quotient for each field in the array- Parameters:
arrDividend- the array holding the dividenddivisor- the divisor each field is divided by- Since:
- 1.4.0 com.github.kilianB
-
divide
public static void divide(double[] arrDividend, double divisor)Calculate the quotient for each field in the array- Parameters:
arrDividend- the array holding the dividenddivisor- the divisor each field is divided by- Since:
- 1.4.0 com.github.kilianB
-
multiply
public static void multiply(byte[] arr, byte[] factors)Pairwise multiply the two vectors.res[i] = a[i] * b[i]- Parameters:
arr- the array to be multiplied by the factorsfactors- of the multiplication.- Throws:
IndexOutOfBoundsException- if factors array is shorter than the first array- Since:
- 1.4.3 com.github.kilianB
-
multiply
public static void multiply(char[] arr, char[] factors)Pairwise multiply the two vectors.res[i] = a[i] * b[i]- Parameters:
arr- the array to be multiplied by the factorsfactors- of the multiplication.- Throws:
IndexOutOfBoundsException- if factors array is shorter than the first array- Since:
- 1.4.3 com.github.kilianB
-
multiply
public static void multiply(short[] arr, short[] factors)Pairwise multiply the two vectors.res[i] = a[i] * b[i]- Parameters:
arr- the array to be multiplied by the factorsfactors- of the multiplication.- Throws:
IndexOutOfBoundsException- if factors array is shorter than the first array- Since:
- 1.4.3 com.github.kilianB
-
multiply
public static void multiply(int[] arr, int[] factors)Pairwise multiply the two vectors.res[i] = a[i] * b[i]- Parameters:
arr- the array to be multiplied by the factorsfactors- of the multiplication.- Throws:
IndexOutOfBoundsException- if factors array is shorter than the first array- Since:
- 1.4.3 com.github.kilianB
-
multiply
public static void multiply(long[] arr, long[] factors)Pairwise multiply the two vectors.res[i] = a[i] * b[i]- Parameters:
arr- the array to be multiplied by the factorsfactors- of the multiplication.- Throws:
IndexOutOfBoundsException- if factors array is shorter than the first array- Since:
- 1.4.3 com.github.kilianB
-
multiply
public static void multiply(float[] arr, float[] factors)Pairwise multiply the two vectors.res[i] = a[i] * b[i]- Parameters:
arr- the array to be multiplied by the factorsfactors- of the multiplication.- Throws:
IndexOutOfBoundsException- if factors array is shorter than the first array- Since:
- 1.4.3 com.github.kilianB
-
multiply
public static void multiply(double[] arr, double[] factors)Pairwise multiply the two vectors.res[i] = a[i] * b[i]- Parameters:
arr- the array to be multiplied by the factorsfactors- of the multiplication.- Throws:
IndexOutOfBoundsException- if factors array is shorter than the first array- Since:
- 1.4.3 com.github.kilianB
-
divide
public static void divide(byte[] arrDivisor, byte[] dividend)Pairwise divide the two vectors.res[i] = a[i] / b[i]- Parameters:
arrDivisor- the array to be divided by the dividenddividend- of the division.- Throws:
IndexOutOfBoundsException- if dividend array is shorter than the first array- Since:
- 1.4.3 com.github.kilianB
-
divide
public static void divide(char[] arrDivisor, char[] dividend)Pairwise divide the two vectors.res[i] = a[i] / b[i]- Parameters:
arrDivisor- the array to be divided by the dividenddividend- of the division.- Throws:
IndexOutOfBoundsException- if dividend array is shorter than the first array- Since:
- 1.4.3 com.github.kilianB
-
divide
public static void divide(short[] arrDivisor, short[] dividend)Pairwise divide the two vectors.res[i] = a[i] / b[i]- Parameters:
arrDivisor- the array to be divided by the dividenddividend- of the division.- Throws:
IndexOutOfBoundsException- if dividend array is shorter than the first array- Since:
- 1.4.3 com.github.kilianB
-
divide
public static void divide(int[] arrDivisor, int[] dividend)Pairwise divide the two vectors.res[i] = a[i] / b[i]- Parameters:
arrDivisor- the array to be divided by the dividenddividend- of the division.- Throws:
IndexOutOfBoundsException- if dividend array is shorter than the first array- Since:
- 1.4.3 com.github.kilianB
-
divide
public static void divide(long[] arrDivisor, long[] dividend)Pairwise divide the two vectors.res[i] = a[i] / b[i]- Parameters:
arrDivisor- the array to be divided by the dividenddividend- of the division.- Throws:
IndexOutOfBoundsException- if dividend array is shorter than the first array- Since:
- 1.4.3 com.github.kilianB
-
divide
public static void divide(float[] arrDivisor, float[] dividend)Pairwise divide the two vectors.res[i] = a[i] / b[i]- Parameters:
arrDivisor- the array to be divided by the dividenddividend- of the division.- Throws:
IndexOutOfBoundsException- if dividend array is shorter than the first array- Since:
- 1.4.3 com.github.kilianB
-
divide
public static void divide(double[] arrDivisor, double[] dividend)Pairwise divide the two vectors.res[i] = a[i] / b[i]- Parameters:
arrDivisor- the array to be divided by the dividenddividend- of the division.- Throws:
IndexOutOfBoundsException- if dividend array is shorter than the first array- Since:
- 1.4.3 com.github.kilianB
-
average
public static double average(byte[] array)
Calculates the average value of the array.- Parameters:
array- the array to compute the average value for- Returns:
- the average value of the array or 0 if the array has a length of 0
- Since:
- 1.5.5 com.github.kilianB
-
average
public static double average(char[] array)
Calculates the average value of the array.- Parameters:
array- the array to compute the average value for- Returns:
- the average value of the array or 0 if the array has a length of 0
- Since:
- 1.5.5 com.github.kilianB
-
average
public static double average(short[] array)
Calculates the average value of the array.- Parameters:
array- the array to compute the average value for- Returns:
- the average value of the array or 0 if the array has a length of 0
- Since:
- 1.5.5 com.github.kilianB
-
average
public static double average(int[] array)
Calculates the average value of the array.- Parameters:
array- the array to compute the average value for- Returns:
- the average value of the array or 0 if the array has a length of 0
- Since:
- 1.5.5 com.github.kilianB
-
average
public static double average(long[] array)
Calculates the average value of the array.- Parameters:
array- the array to compute the average value for- Returns:
- the average value of the array or 0 if the array has a length of 0
- Since:
- 1.5.5 com.github.kilianB
-
average
public static double average(float[] array)
Calculates the average value of the array.- Parameters:
array- the array to compute the average value for- Returns:
- the average value of the array or 0 if the array has a length of 0
- Since:
- 1.5.5 com.github.kilianB
-
average
public static double average(double[] array)
Calculates the average value of the array.- Parameters:
array- the array to compute the average value for- Returns:
- the average value of the array or 0 if the array has a length of 0
- Since:
- 1.5.5 com.github.kilianB
-
average
public static double average(byte[][] array)
Calculates the average value of the 2d array.- Parameters:
array- the array to compute the average value for- Returns:
- the average value of the array or 0 if the array has a length of 0
- Since:
- 1.5.5 com.github.kilianB
-
average
public static double average(char[][] array)
Calculates the average value of the 2d array.- Parameters:
array- the array to compute the average value for- Returns:
- the average value of the array or 0 if the array has a length of 0
- Since:
- 1.5.5 com.github.kilianB
-
average
public static double average(short[][] array)
Calculates the average value of the 2d array.- Parameters:
array- the array to compute the average value for- Returns:
- the average value of the array or 0 if the array has a length of 0
- Since:
- 1.5.5 com.github.kilianB
-
average
public static double average(int[][] array)
Calculates the average value of the 2d array.- Parameters:
array- the array to compute the average value for- Returns:
- the average value of the array or 0 if the array has a length of 0
- Since:
- 1.5.5 com.github.kilianB
-
average
public static double average(long[][] array)
Calculates the average value of the 2d array.- Parameters:
array- the array to compute the average value for- Returns:
- the average value of the array or 0 if the array has a length of 0
- Since:
- 1.5.5 com.github.kilianB
-
average
public static double average(float[][] array)
Calculates the average value of the 2d array.- Parameters:
array- the array to compute the average value for- Returns:
- the average value of the array or 0 if the array has a length of 0
- Since:
- 1.5.5 com.github.kilianB
-
average
public static double average(double[][] array)
Calculates the average value of the 2d array.- Parameters:
array- the array to compute the average value for- Returns:
- the average value of the array or 0 if the array has a length of 0
- Since:
- 1.5.5 com.github.kilianB
-
median
public static double median(byte[] array)
Calculate the median value of the array- Parameters:
array- the array to calculate the median value for.- Returns:
- the median value of the array
- Throws:
ArrayIndexOutOfBoundsException- if the array has a length of 0- Since:
- 1.5.5 com.github.kilianB
-
median
public static double median(char[] array)
Calculate the median value of the array- Parameters:
array- the array to calculate the median value for.- Returns:
- the median value of the array
- Throws:
ArrayIndexOutOfBoundsException- if the array has a length of 0- Since:
- 1.5.5 com.github.kilianB
-
median
public static double median(short[] array)
Calculate the median value of the array- Parameters:
array- the array to calculate the median value for.- Returns:
- the median value of the array
- Throws:
ArrayIndexOutOfBoundsException- if the array has a length of 0- Since:
- 1.5.5 com.github.kilianB
-
median
public static double median(int[] array)
Calculate the median value of the array- Parameters:
array- the array to calculate the median value for.- Returns:
- the median value of the array
- Throws:
ArrayIndexOutOfBoundsException- if the array has a length of 0- Since:
- 1.5.5 com.github.kilianB
-
median
public static double median(long[] array)
Calculate the median value of the array- Parameters:
array- the array to calculate the median value for.- Returns:
- the median value of the array
- Throws:
ArrayIndexOutOfBoundsException- if the array has a length of 0- Since:
- 1.5.5 com.github.kilianB
-
median
public static double median(float[] array)
Calculate the median value of the array- Parameters:
array- the array to calculate the median value for.- Returns:
- the median value of the array
- Throws:
ArrayIndexOutOfBoundsException- if the array has a length of 0- Since:
- 1.5.5 com.github.kilianB
-
median
public static double median(double[] array)
Calculate the median value of the array- Parameters:
array- the array to calculate the median value for.- Returns:
- the median value of the array
- Throws:
ArrayIndexOutOfBoundsException- if the array has a length of 0- Since:
- 1.5.5 com.github.kilianB
-
get
public static <T> T get(Object array, int... index)
-
-