juggernaut.mef

Class Lists

public class Lists extends Object

Method Summary
static int[]cumSum(int[] array)
Goes through the array and inserts a the current total of the array to a new array in the same element.
static double[]cumSum(double[] array)
Goes through the array and inserts a the current total of the array to a new array in the same element.
static voidfill(int[] array, int x)
Fills an integer array with a specified integer.
static voidfill(double[] array, double x)
Fills a double array with a specified double.
static double[]getArgsDouble(String[] args)
Takes each element in an String array and changes it into a {@code double} using {@code Double.parseDouble()}.
static int[]getArgsInt(String[] args)
Takes each element in an String array and changes it into an {@code int} using {@code Integer.parseInt()}.
static intmax(int[] array)
Returns the index of the element with the largest value in the array.
static doublemax(double[] array)
Returns the index of the element with the largest value in the array.
static doublemean(int[] array)
Returns the arithmetic mean of an array.
static doublemean(double[] array)
Returns the arithmetic mean of an array.
static intmin(int[] array)
Returns the index of the element with the smallest value in the array.
static doublemin(double[] array)
Returns the index of the element with the smallest value in the array.
static intproduct(int[] array)
Returns the product of all the elements in the array multiplied together.
static intproduct(double[] array)
Returns the product of all the elements in the array multiplied together.
static double[]randDoubleList(int length)
Returns a list of random {@code doubles} between 0 and 1.
static double[]randDoubleList(int length, double lower, double upper)
Returns a list of random {@code doubles}.
static int[]randIntList(int length, int lower, int upper)
Returns a list of random integers.
static long[]randLongList(int length, long lower, long upper)
Returns a list of random {@code longs}.
static intsearch(int[] array, int n, int start)
Searches through an integer array for a specified integer, beginning from start and returning the index of the first occurrence of that integer.
static doublesearch(double[] array, double n, int start)
Searches through a double array for a specified double, beginning from start and returning the index of the first occurrence of that double.
static doublestdDev(int[] array)
Returns the standard deviation of an integer array.
static doublestdDev(double[] array)
Returns the standard deviation of a double array.
static intsum(int[] array)
Adds all of the elements of the array together and returns the sum.
static doublesum(double[] array)
Adds all of the elements of the array together and returns the sum.
static voidswap(int[] array, int a, int b)
Swaps the element at index a with the element at index b.
static voidswap(Object[] array, int a, int b)
Swaps the element at index a with the element at index b.
static boolean[]testEquals(int[] array, int value)
static int[]testEquals(int[] array, int[] array2)
static int[]testEquals(double[] array, double value)
static int[]testEquals(double[] array, double[] array2)
static StringtoString(Object[] array)
Returns a string version of an array in the following format: [1, 2, 3, ...
static StringtoString(double[] array)
Returns a string version of an array in the following format: [1, 2, 3, ...
static StringtoString(int[] array)
Returns a string version of an array in the following format: [1, 2, 3, ...
static doublevariance(int[] array)
Returns the variance of the array.
static doublevariance(double[] array)
Returns the variance of the array.

Method Detail

cumSum

public static int[] cumSum(int[] array)
Goes through the array and inserts a the current total of the array to a new array in the same element. For instance {@code cumSum([1,2,3,4,5])} = [1 3 6 10 15].

Parameters: array the integer array

Returns: The cumulative sum of the array.

cumSum

public static double[] cumSum(double[] array)
Goes through the array and inserts a the current total of the array to a new array in the same element. For instance {@code cumSum([1,2,3,4,5])} = [1 3 6 10 15].

Parameters: array the integer array

Returns: The cumulative sum of the array.

fill

public static void fill(int[] array, int x)
Fills an integer array with a specified integer.

Parameters: array an integer array x what to fill the array with

fill

public static void fill(double[] array, double x)
Fills a double array with a specified double.

Parameters: array a double array x what to fill the array with

getArgsDouble

public static double[] getArgsDouble(String[] args)
Takes each element in an String array and changes it into a {@code double} using {@code Double.parseDouble()}.

Parameters: args the array of strings to be converted

Returns: A double array which has the values of the String array.

getArgsInt

public static int[] getArgsInt(String[] args)
Takes each element in an String array and changes it into an {@code int} using {@code Integer.parseInt()}.

Parameters: args the array of strings to be converted

Returns: An int array which has the values of the String array.

max

public static int max(int[] array)
Returns the index of the element with the largest value in the array.

Parameters: array an integer array

Returns: The index of the element of the largest value in the array.

max

public static double max(double[] array)
Returns the index of the element with the largest value in the array.

Parameters: array a double array

Returns: The index of the element of the largest value in the array.

mean

public static double mean(int[] array)
Returns the arithmetic mean of an array.

Parameters: array an integer array

Returns: The arithmetic mean of the array.

mean

public static double mean(double[] array)
Returns the arithmetic mean of an array.

Parameters: array a double array

Returns: The arithmetic mean of the array.

min

public static int min(int[] array)
Returns the index of the element with the smallest value in the array.

Parameters: array an int array

Returns: The index of the element of the smallest value in the array.

min

public static double min(double[] array)
Returns the index of the element with the smallest value in the array.

Parameters: array a double array

Returns: The index of the element of the smallest value in the array.

product

public static int product(int[] array)
Returns the product of all the elements in the array multiplied together.

Parameters: array an integer array

Returns: The product of all the elements.

product

public static int product(double[] array)
Returns the product of all the elements in the array multiplied together.

Parameters: array a double array

Returns: The product of all the elements.

randDoubleList

public static double[] randDoubleList(int length)
Returns a list of random {@code doubles} between 0 and 1.

Parameters: length the length of the list.

Returns: The random {@code double} array.

randDoubleList

public static double[] randDoubleList(int length, double lower, double upper)
Returns a list of random {@code doubles}.

Parameters: length the length of the list. lower the lower bound of the {@code doubles}. upper the upper bound of the {@code doubles}.

Returns: The random {@code double} array.

randIntList

public static int[] randIntList(int length, int lower, int upper)
Returns a list of random integers.

Parameters: length the length of the list. lower the lower bound of the integers. upper the upper bound of the integers.

Returns: The random {@code int} array.

randLongList

public static long[] randLongList(int length, long lower, long upper)
Returns a list of random {@code longs}.

Parameters: length the length of the list. lower the lower bound of the {@code longs}. upper the upper bound of the {@code longs}.

Returns: The random {@code long} array.

search

public static int search(int[] array, int n, int start)
Searches through an integer array for a specified integer, beginning from start and returning the index of the first occurrence of that integer.

Parameters: array an integer array n the integer to search for start the starting index of the search

Returns: The index of the first element equal to n. If not found, will return 0.

search

public static double search(double[] array, double n, int start)
Searches through a double array for a specified double, beginning from start and returning the index of the first occurrence of that double.

Parameters: array a double array n the double to search for start the starting index of the search

Returns: The index of the first element equal to n. If not found, will return 0.

stdDev

public static double stdDev(int[] array)
Returns the standard deviation of an integer array. Found by taking the square root of the variance.

Parameters: array an integer array

Returns: The standard deviation of the array.

stdDev

public static double stdDev(double[] array)
Returns the standard deviation of a double array. Found by taking the square root of the variance.

Parameters: array a double array

Returns: The standard deviation of the array.

sum

public static int sum(int[] array)
Adds all of the elements of the array together and returns the sum.

Parameters: array an integer array

Returns: The sum of the array.

sum

public static double sum(double[] array)
Adds all of the elements of the array together and returns the sum.

Parameters: array a double array

Returns: The sum of the array.

swap

public static void swap(int[] array, int a, int b)
Swaps the element at index a with the element at index b.

Parameters: array an integer array a the first index in the array b the second index in the array

swap

public static void swap(Object[] array, int a, int b)
Swaps the element at index a with the element at index b.

Parameters: array an object array a the first index in the array b the second index in the array

testEquals

public static boolean[] testEquals(int[] array, int value)

testEquals

public static int[] testEquals(int[] array, int[] array2)

testEquals

public static int[] testEquals(double[] array, double value)

testEquals

public static int[] testEquals(double[] array, double[] array2)

toString

public static String toString(Object[] array)
Returns a string version of an array in the following format: [1, 2, 3, ... N]

Parameters: array an object array.

Returns: The array in string format.

toString

public static String toString(double[] array)
Returns a string version of an array in the following format: [1, 2, 3, ... N]

Parameters: array a double array.

Returns: The array in string format.

toString

public static String toString(int[] array)
Returns a string version of an array in the following format: [1, 2, 3, ... N]

Parameters: array an int array.

Returns: The array in string format.

variance

public static double variance(int[] array)
Returns the variance of the array.

Parameters: array an integer array

Returns: The variance of the array.

variance

public static double variance(double[] array)
Returns the variance of the array.

Parameters: array a double array

Returns: The variance of the array.