Package jebl.util
Class Utils
java.lang.Object
jebl.util.Utils
Provides some miscellaneous methods.
- Version:
- $Id: Utils.java 849 2007-12-06 00:10:14Z twobeers $
- Author:
- Matthew Goode
-
Method Summary
Modifier and TypeMethodDescriptionstatic void
copy
(double[][] source, double[][] dest) Copies all of source into dest - assumes dest to be large enoughstatic int
getArgmax
(double[] array) Find the maximum "argument" (of a double array).static int
getArgmax
(int[] array) Find the maximum "argument".static boolean[][]
getCopy
(boolean[][] array) Clones an array of booleansstatic byte[]
getCopy
(byte[] array) Clones an array of bytesstatic byte[][]
getCopy
(byte[][] array) Clones an array of bytesstatic double[]
getCopy
(double[] array) Clones an array of doublesstatic double[][]
getCopy
(double[][] array) Clones an array of doublesstatic double[][][]
getCopy
(double[][][] array) Clones an array of doublesstatic double[]
getCopy
(double[] array, int start) Clones an array of doubles from index start (inclusive) to endstatic double[]
getCopy
(double[] array, int start, int end) Clones an array of doubles from index start (inclusive) to index end (exclusive)static int[]
getCopy
(int[] array) Clones an array of intsstatic int[][]
getCopy
(int[][] matrix) Clones a matrix of intsstatic int[]
getCopy
(int[] array, int startingIndex) Clones an array of intsstatic String[]
Clones an array of Stringsstatic double
getMax
(double[] array) Calculate the max of an arraystatic double
getMax
(double[] array, int start, int end) Calculate the max of an arraystatic double
getMean
(double[] array) Calculate the mean value of an arraystatic double
getMin
(double[] array) Calculate the min of an arraystatic double
getSum
(double[] array) Calculate the total of an arraystatic boolean
isContains
(String[] set, String query) Test if a string occurs within a setstatic String
toString
(double[] array) A simple toString method for an array of doubles.static String
toString
(double[][] array) A simple toString method for an array of doubles.static String
toString
(double[] array, int number) A simple toString method for an array of doubles.static String
toString
(int[] array) A simple toString method for an array of ints.static String
toString
(int[][] array) A simple toString method for an array of ints.static String
toString
(int[] array, int number) static String
A simple toString method for an array of doubles.static String
A simple toString method for an array of objects.static String
A simple toString method for an array of objects.static String
A simple toString method for an array of objects.
-
Method Details
-
isContains
Test if a string occurs within a set- Parameters:
set
- the set of stringsquery
- the query string- Returns:
- true if the query string is in the set (as determined by object equality)
-
getCopy
public static double[] getCopy(double[] array) Clones an array of doubles- Returns:
- null if input is null, otherwise return complete copy.
-
getSum
public static double getSum(double[] array) Calculate the total of an array- Parameters:
array
- The array to sum up- Returns:
- the sum of all the elements
-
getMax
public static double getMax(double[] array) Calculate the max of an array- Parameters:
array
- The array to check- Returns:
- the max of all the elements
-
getMax
public static double getMax(double[] array, int start, int end) Calculate the max of an array- Parameters:
array
- The array to checkstart
- the first index to checkend
- the index after the last index to check- Returns:
- the max of all the elements
-
getMin
public static double getMin(double[] array) Calculate the min of an array- Parameters:
array
- The array to check- Returns:
- the min of all the elements
-
getMean
public static double getMean(double[] array) Calculate the mean value of an array- Parameters:
array
- the values- Returns:
- the average
-
getCopy
public static double[] getCopy(double[] array, int start, int end) Clones an array of doubles from index start (inclusive) to index end (exclusive)- Returns:
- null if input is null
-
getCopy
public static double[] getCopy(double[] array, int start) Clones an array of doubles from index start (inclusive) to end- Returns:
- null if input is null
-
getCopy
public static byte[] getCopy(byte[] array) Clones an array of bytes- Parameters:
array
- the bytes to copy- Returns:
- null if input is null, otherwise return complete copy.
-
getCopy
Clones an array of Strings- Parameters:
array
- the strings to copy- Returns:
- null if input is null, otherwise return complete copy.
-
getCopy
public static double[][] getCopy(double[][] array) Clones an array of doubles- Returns:
- null if input is null, otherwise return complete copy.
-
getCopy
public static int[][] getCopy(int[][] matrix) Clones a matrix of ints- Parameters:
matrix
- the matrix to clone- Returns:
- null if input is null, otherwise return complete copy.
-
getCopy
public static double[][][] getCopy(double[][][] array) Clones an array of doubles- Returns:
- null if input is null, otherwise return complete copy.
-
getCopy
public static byte[][] getCopy(byte[][] array) Clones an array of bytes- Returns:
- null if input is null, otherwise return complete copy.
-
getCopy
public static boolean[][] getCopy(boolean[][] array) Clones an array of booleans- Returns:
- null if input is null, otherwise return complete copy.
-
getCopy
public static int[] getCopy(int[] array) Clones an array of ints- Returns:
- null if input is null, otherwise return complete copy.
-
getCopy
public static int[] getCopy(int[] array, int startingIndex) Clones an array of ints- Returns:
- null if input is null, otherwise return complete copy.
-
copy
public static void copy(double[][] source, double[][] dest) Copies all of source into dest - assumes dest to be large enough -
toString
A simple toString method for an array of doubles. No fancy formating. Puts spaces between each value- Parameters:
number
- number of elements to process starting from first element
-
toString
A simple toString method for an array of objects. No fancy formating. Puts spaces between each value- Parameters:
number
- number of elements to process starting from first element
-
toString
A simple toString method for an array of objects. No fancy formating. Puts user defined string between each value -
toString
A simple toString method for an array of objects. No fancy formating. Puts user defined string between each value- Parameters:
number
- number of elements to process starting from first element
-
toString
A simple toString method for an array of doubles. No fancy formating. Puts spaces between each value -
toString
A simple toString method for an array of doubles. No fancy formating. Puts spaces between each value -
toString
A simple toString method for an array of ints. No fancy formating. Puts spaces between each value -
toString
-
toString
A simple toString method for an array of doubles. No fancy formating. Puts spaces between each value -
toString
A simple toString method for an array of ints. No fancy formating. Puts spaces between each value -
getArgmax
public static int getArgmax(int[] array) Find the maximum "argument". if array is zero length returns -1- Parameters:
array
- The array to examine- Returns:
- the element of the array with the maximum value
-
getArgmax
public static int getArgmax(double[] array) Find the maximum "argument" (of a double array). if array is zero length returns -1- Parameters:
array
- The array to examine- Returns:
- the element of the array with the maximum value
-