shared
Class MLJArray

java.lang.Object
  |
  +--shared.MLJArray

public class MLJArray
extends java.lang.Object

This class includes methods useful in the manipulation of arrays. All of the functions are static to make the use of this class easier for any type of array.


Method Summary
static boolean[] copy(boolean[] source)
          Copies the given boolean array and returns the copy.
static double[] copy(double[] source)
          Copies the given double array and returns the copy.
static int[] copy(int[] source)
          Copies the given integer array and returns the copy.
static int find(double key, int startPosition, double[] array)
          Searches an array of double values for a specified value.
static void init_values(double initialValue, double[] array)
          Initializes an array to a specified double value.
static void init_values(int initialValue, int[] array)
          Initializes an array to a specified integer value.
static double max(IntRef index, double[] array)
          Finds the maximum value in an array of double values.
static int num_element(boolean key, boolean[] array)
          Counts the number of values in a boolean array match a specified value.
static int sort_compare(Sortable a, Sortable b)
          Deprecated.  
static void sort(int[] theArray)
          Sorts the specified array of integers.
static void sort(java.lang.Object[] theArray, java.lang.reflect.Method sortMethod)
          Deprecated.  
static void sort(Sortable[] theArray)
          Deprecated.  
static double sum(double[] array)
          Returns the sum of an array of double values.
static java.lang.Object[] truncate(int newSize, java.lang.Object[] array)
          This function truncates an array of Objects.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

sum

public static double sum(double[] array)
Returns the sum of an array of double values.
Parameters:
array - The array of double values to be added.
Returns:
The sum of the array.

init_values

public static void init_values(double initialValue,
                               double[] array)
Initializes an array to a specified double value.
Parameters:
initialValue - The value to be initialized.
array - The array to be initialized.

init_values

public static void init_values(int initialValue,
                               int[] array)
Initializes an array to a specified integer value.
Parameters:
initialValue - The value to be initialized.
array - The array to be initialized.

sort_compare

public static int sort_compare(Sortable a,
                               Sortable b)
Deprecated.  

Comparison function for the sort algorithm.
Parameters:
a - The first item to be compared.
b - The second item to be compared.
Returns:
An integer representing the result of the comparison. The possible values are -1, 0, 1.

sort

public static void sort(Sortable[] theArray)
Deprecated.  

Sorts the array of Objects that implement the Sortable Interface.
Parameters:
theArray - The array to be sorted. The objects in the array must implment the sortable interface.

sort

public static void sort(java.lang.Object[] theArray,
                        java.lang.reflect.Method sortMethod)
Deprecated.  

Sorts the specified array by the method supplied.
Parameters:
theArray - The array to be sorted.
sortMethod - The Method used for sorting.

max

public static double max(IntRef index,
                         double[] array)
Finds the maximum value in an array of double values.
Parameters:
index - An IntRef holding the place of the maximum value in the array.
array - The array to be searched.
Returns:
The maximum value.

find

public static int find(double key,
                       int startPosition,
                       double[] array)
Searches an array of double values for a specified value.
Parameters:
key - The value to be searched for.
startPosition - The array index to start searching from.
array - The array to be searched.
Returns:
The first index of the value searched for if found, otherwise -1.

sort

public static void sort(int[] theArray)
Sorts the specified array of integers.
Parameters:
theArray - The array to be sorted. The array is changed by the use of this method.

num_element

public static int num_element(boolean key,
                              boolean[] array)
Counts the number of values in a boolean array match a specified value.
Parameters:
key - The value to be searched for.
array - The array to be searched.
Returns:
The number of elements which match the specified value.

copy

public static int[] copy(int[] source)
Copies the given integer array and returns the copy.
Parameters:
source - The array to be copied.
Returns:
The new copy.

copy

public static double[] copy(double[] source)
Copies the given double array and returns the copy.
Parameters:
source - The array to be copied.
Returns:
The new copy.

copy

public static boolean[] copy(boolean[] source)
Copies the given boolean array and returns the copy.
Parameters:
source - The array to be copied.
Returns:
The new copy.

truncate

public static java.lang.Object[] truncate(int newSize,
                                          java.lang.Object[] array)
This function truncates an array of Objects.
Parameters:
newSize - The new size of the array.
array - The array to be truncated.
Returns:
The truncated array.