papaya
Class Find

java.lang.Object
  extended by papaya.Find
All Implemented Interfaces:
PapayaConstants

public final class Find
extends Object
implements PapayaConstants

Static class for finding indices in an array corresponding to a given value/object.

(Portions of this code were (conveniently!) copied and pasted from commons.apache.org.) :)


Field Summary
 
Fields inherited from interface papaya.PapayaConstants
BASELINE, big, biginv, BOTTOM, CENTER, CORNER, FONTNAME, GRAY, INDEX_NOT_FOUND, INDICES_NOT_FOUND, LEFT, LOGPI, MACHEP, MAXGAM, MAXLOG, MINLOG, RIGHT, SQRTH, SQTPI, STROKEWEIGHT, TEXTSIZE, TOP
 
Method Summary
static boolean contains(byte[] array, byte valueToFind)
          Checks if the value is in the given array.
static boolean contains(char[] array, char valueToFind)
          Checks if the value is in the given array.
static boolean contains(double[] array, double valueToFind)
          Checks if the value is in the given array.
static boolean contains(double[] array, double valueToFind, double tolerance)
          Checks if a value falling within the given tolerance is in the given array.
static boolean contains(float[] array, float valueToFind)
          Checks if the value is in the given array.
static boolean contains(int[] array, int valueToFind)
          Checks if the value is in the given array.
static boolean contains(long[] array, long valueToFind)
          Checks if the value is in the given array.
static boolean contains(Object[] array, Object objectToFind)
          Checks if the object is in the given array.
static boolean contains(short[] array, short valueToFind)
          Checks if the value is in the given array.
static int indexOf(boolean[] array, boolean valueToFind)
          Finds the index of the given value in the array.
static int indexOf(boolean[] array, boolean valueToFind, int startIndex)
          Finds the index of the given value in the array starting at the given index.
static int indexOf(byte[] array, byte valueToFind)
          Finds the index of the given value in the array.
static int indexOf(byte[] array, byte valueToFind, int startIndex)
          Finds the index of the given value in the array starting at the given index.
static int indexOf(char[] array, char valueToFind)
          Finds the index of the given value in the array.
static int indexOf(char[] array, char valueToFind, int startIndex)
          Finds the index of the given value in the array starting at the given index.
static int indexOf(double[] array, double valueToFind)
          Finds the index of the given value in the array.
static int indexOf(double[] array, double valueToFind, double tolerance)
          Finds the index of the given value within a given tolerance in the array.
static int indexOf(double[] array, double valueToFind, int startIndex)
          Finds the index of the given value in the array starting at the given index.
static int indexOf(double[] array, double valueToFind, int startIndex, double tolerance)
          Finds the index of the given value in the array starting at the given index.
static int indexOf(float[] array, float valueToFind)
          Finds the index of the given value in the array.
static int indexOf(float[] array, float valueToFind, int startIndex)
          Finds the index of the given value in the array starting at the given index.
static int indexOf(int[] array, int valueToFind)
          Finds the index of the given value in the array.
static int indexOf(int[] array, int valueToFind, int startIndex)
          Finds the index of the given value in the array starting at the given index.
static int indexOf(long[] array, long valueToFind)
          Finds the index of the given value in the array.
static int indexOf(long[] array, long valueToFind, int startIndex)
          Finds the index of the given value in the array starting at the given index.
static int indexOf(Object[] array, Object objectToFind)
          Finds the index of the given object in the array.
static int indexOf(Object[] array, Object objectToFind, int startIndex)
          Finds the index of the given object in the array starting at the given index.
static int indexOf(short[] array, short valueToFind)
          Finds the index of the given value in the array.
static int indexOf(short[] array, short valueToFind, int startIndex)
          Finds the index of the given value in the array starting at the given index.
static int[] indicesGreaterThan(float[] array, float valueOfMin)
           
static int[] indicesGreaterThan(int[] array, int valueOfMin)
           
static int[] indicesGreaterThanOrEqualTo(float[] array, float valueOfMin)
           
static int[] indicesGreaterThanOrEqualTo(int[] array, int valueOfMin)
           
static int[] indicesLessThan(float[] array, float valueOfMax)
           
static int[] indicesLessThan(int[] array, int valueOfMax)
           
static int[] indicesLessThanOrEqualTo(float[] array, float valueOfMax)
           
static int[] indicesLessThanOrEqualTo(int[] array, int valueOfMax)
           
static int[] indicesWith(boolean[] array, boolean valueToFind)
          Finds the indices containing the specified value in the array.
static int[] indicesWith(boolean[] array, boolean valueToFind, int startIndex)
          Finds the indices containing the specified value in the array.
static int[] indicesWith(byte[] array, byte valueToFind)
          Finds the indices containing the specified value in the array.
static int[] indicesWith(byte[] array, byte valueToFind, int startIndex)
          Finds the indices containing the specified value in the array.
static int[] indicesWith(char[] array, char valueToFind)
          Finds the indices containing the specified value in the array.
static int[] indicesWith(char[] array, char valueToFind, int startIndex)
          Finds the indices containing the specified value in the array.
static int[] indicesWith(double[] array, double valueToFind)
          Finds the indices containing the specified value in the array.
static int[] indicesWith(double[] array, double valueToFind, int startIndex)
          Finds the indices containing the specified value in the array.
static int[] indicesWith(float[] array, float valueToFind)
          Finds the indices containing the specified value in the array.
static int[] indicesWith(float[] array, float valueToFind, int startIndex)
          Finds the indices containing the specified value in the array.
static int[] indicesWith(int[] array, int valueToFind)
          Finds the indices containing the specified value in the array.
static int[] indicesWith(int[] array, int valueToFind, int startIndex)
          Finds the indices containing the specified value in the array.
static int[] indicesWith(long[] array, long valueToFind)
          Finds the indices containing the specified value in the array.
static int[] indicesWith(long[] array, long valueToFind, int startIndex)
          Finds the indices containing the specified value in the array.
static int[] indicesWith(Object[] array, Object objectToFind)
          Finds the indices containing the specified object in the array.
static int[] indicesWith(Object[] array, Object objectToFind, int startIndex)
          Finds the indices containing the specified object in the array.
static int[] indicesWith(short[] array, short valueToFind)
          Finds the indices containing the specified value in the array.
static int[] indicesWith(short[] array, short valueToFind, int startIndex)
          Finds the indices containing the specified value in the array.
static int[] indicesWithin(float[] array, float minVal, float maxVal)
          Finds the indices for the array elements within the min and max value (inclusive).
static int[] indicesWithin(int[] array, float minVal, float maxVal)
          Finds the indices for the array elements within the min and max value (inclusive).
static int lastIndexOf(boolean[] array, boolean valueToFind)
          Finds the last index of the given value within the array.
static int lastIndexOf(boolean[] array, boolean valueToFind, int startIndex)
          Finds the last index of the given value in the array starting at the given index.
static int lastIndexOf(byte[] array, byte valueToFind)
          Finds the last index of the given value within the array.
static int lastIndexOf(byte[] array, byte valueToFind, int startIndex)
          Finds the last index of the given value in the array starting at the given index.
static int lastIndexOf(char[] array, char valueToFind)
          Finds the last index of the given value within the array.
static int lastIndexOf(char[] array, char valueToFind, int startIndex)
          Finds the last index of the given value in the array starting at the given index.
static int lastIndexOf(double[] array, double valueToFind)
          Finds the last index of the given value within the array.
static int lastIndexOf(double[] array, double valueToFind, double tolerance)
          Finds the last index of the given value within a given tolerance in the array.
static int lastIndexOf(double[] array, double valueToFind, int startIndex)
          Finds the last index of the given value in the array starting at the given index.
static int lastIndexOf(double[] array, double valueToFind, int startIndex, double tolerance)
          Finds the last index of the given value in the array starting at the given index.
static int lastIndexOf(float[] array, float valueToFind)
          Finds the last index of the given value within the array.
static int lastIndexOf(float[] array, float valueToFind, int startIndex)
          Finds the last index of the given value in the array starting at the given index.
static int lastIndexOf(int[] array, int valueToFind)
          Finds the last index of the given value within the array.
static int lastIndexOf(int[] array, int valueToFind, int startIndex)
          Finds the last index of the given value in the array starting at the given index.
static int lastIndexOf(long[] array, long valueToFind)
          Finds the last index of the given value within the array.
static int lastIndexOf(long[] array, long valueToFind, int startIndex)
          Finds the last index of the given value in the array starting at the given index.
static int lastIndexOf(Object[] array, Object objectToFind)
          Finds the last index of the given object within the array.
static int lastIndexOf(Object[] array, Object objectToFind, int startIndex)
          Finds the last index of the given object in the array starting at the given index.
static int lastIndexOf(short[] array, short valueToFind)
          Finds the last index of the given value within the array.
static int lastIndexOf(short[] array, short valueToFind, int startIndex)
          Finds the last index of the given value in the array starting at the given index.
static int numGreaterThan(float[] array, float valueOfMin)
          Finds the number of elements strictly greater than the specified value.
static int numGreaterThan(int[] array, int valueOfMin)
          Finds the number of elements strictly greater than the specified value.
static int numGreaterThanOrEqualTo(float[] array, float valueOfMin)
          Finds the number of elements greater than or equal to the specified value.
static int numGreaterThanOrEqualTo(int[] array, int valueOfMin)
          Finds the number of elements greater than or equal to the specified value.
static int numLessThan(float[] array, float valueOfMax)
          Finds the number of elements strictly less than the specified value.
static int numLessThan(int[] array, int valueOfMax)
          Finds the number of elements strictly less than the specified value.
static int numLessThanOrEqualTo(float[] array, float valueOfMax)
          Finds the number of elements less than or equal to the specified value.
static int numLessThanOrEqualTo(int[] array, int valueOfMax)
          Finds the number of elements less than or equal to the specified value.
static int numRepeats(boolean[] array, boolean valueToFind)
          Finds the number of times a given value/object is present in an array.
static int numRepeats(byte[] array, byte valueToFind)
          Finds the number of times a given value/object is present in an array.
static int numRepeats(char[] array, char valueToFind)
          Finds the number of times a given value/object is present in an array.
static int numRepeats(double[] array, double valueToFind)
          Finds the number of times a given value/object is present in an array.
static int numRepeats(float[] array, float valueToFind)
          Finds the number of times a given value/object is present in an array.
static int numRepeats(int[] array, int valueToFind)
          Finds the number of times a given value/object is present in an array.
static int numRepeats(long[] array, long valueToFind)
          Finds the number of times a given value/object is present in an array.
static int numRepeats(Object[] array, Object objectToFind)
          Finds the number of times a given value/object is present in an array.
static int numRepeats(short[] array, short valueToFind)
          Finds the number of times a given value/object is present in an array.
static float[] uniqueElems(float[] array)
          Find the unique elements in a float array (uses HashSets)
static int[] uniqueElems(int[] array)
          Find the unique elements in a int array (uses HashSets)
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

indexOf

public static int indexOf(Object[] array,
                          Object objectToFind)

Finds the index of the given object in the array.

This method returns PapayaConstants.INDEX_NOT_FOUND (-1) for a null input array.

Parameters:
array - the array to search through for the object, may be null
objectToFind - the object to find, may be null
Returns:
the index of the object within the array, PapayaConstants.INDEX_NOT_FOUND (-1) if not found or null array input

indexOf

public static int indexOf(Object[] array,
                          Object objectToFind,
                          int startIndex)

Finds the index of the given object in the array starting at the given index.

This method returns PapayaConstants.INDEX_NOT_FOUND (-1) for a null input array.

A negative startIndex is treated as zero. A startIndex larger than the array length will return PapayaConstants.INDEX_NOT_FOUND (-1).

Parameters:
array - the array to search through for the object, may be null
objectToFind - the object to find, may be null
startIndex - the index to start searching at
Returns:
the index of the object within the array starting at the index, PapayaConstants.INDEX_NOT_FOUND (-1) if not found or null array input

lastIndexOf

public static int lastIndexOf(Object[] array,
                              Object objectToFind)

Finds the last index of the given object within the array.

This method returns PapayaConstants.INDEX_NOT_FOUND (-1) for a null input array.

Parameters:
array - the array to travers backwords looking for the object, may be null
objectToFind - the object to find, may be null
Returns:
the last index of the object within the array, PapayaConstants.INDEX_NOT_FOUND (-1) if not found or null array input

lastIndexOf

public static int lastIndexOf(Object[] array,
                              Object objectToFind,
                              int startIndex)

Finds the last index of the given object in the array starting at the given index.

This method returns PapayaConstants.INDEX_NOT_FOUND (-1) for a null input array.

A negative startIndex will return PapayaConstants.INDEX_NOT_FOUND (-1). A startIndex larger than the array length will search from the end of the array.

Parameters:
array - the array to traverse for looking for the object, may be null
objectToFind - the object to find, may be null
startIndex - the start index to travers backwards from
Returns:
the last index of the object within the array, PapayaConstants.INDEX_NOT_FOUND (-1) if not found or null array input

contains

public static boolean contains(Object[] array,
                               Object objectToFind)

Checks if the object is in the given array.

The method returns false if a null array is passed in.

Parameters:
array - the array to search through
objectToFind - the object to find
Returns:
true if the array contains the object

indicesWith

public static int[] indicesWith(Object[] array,
                                Object objectToFind)

Finds the indices containing the specified object in the array.

This method returns PapayaConstants.INDICES_NOT_FOUND (int[] = -1) for a null input array.

Parameters:
array - the array to search through for the object to find, may be null
objectToFind - the object to find
Returns:
the indices containing the object within the array, PapayaConstants.INDICES_NOT_FOUND (int[] = -1) if not found or null array input

indicesWith

public static int[] indicesWith(Object[] array,
                                Object objectToFind,
                                int startIndex)

Finds the indices containing the specified object in the array.

This method returns PapayaConstants.INDICES_NOT_FOUND (int[] = -1) for a null input array.

Parameters:
array - the array to search through for the object to find, may be null
objectToFind - the object to find
startIndex - the index to start searching at
Returns:
the indices containing the object within the array, PapayaConstants.INDICES_NOT_FOUND (int[] = -1) if not found or null array input

numRepeats

public static int numRepeats(Object[] array,
                             Object objectToFind)

Finds the number of times a given value/object is present in an array.

Parameters:
array - the array to search through for the value/object
objectToFind - the object to find.
Returns:
the number of times that value/object appears in the array PapayaConstants.INDEX_NOT_FOUND (-1) if not found or null array input

indexOf

public static int indexOf(long[] array,
                          long valueToFind)

Finds the index of the given value in the array.

This method returns PapayaConstants.INDEX_NOT_FOUND (-1) for a null input array.

Parameters:
array - the array to search through for the object, may be null
valueToFind - the value to find
Returns:
the index of the value within the array, PapayaConstants.INDEX_NOT_FOUND (-1) if not found or null array input

indexOf

public static int indexOf(long[] array,
                          long valueToFind,
                          int startIndex)

Finds the index of the given value in the array starting at the given index.

This method returns PapayaConstants.INDEX_NOT_FOUND (-1) for a null input array.

A negative startIndex is treated as zero. A startIndex larger than the array length will return PapayaConstants.INDEX_NOT_FOUND (-1).

Parameters:
array - the array to search through for the object, may be null
valueToFind - the value to find
startIndex - the index to start searching at
Returns:
the index of the value within the array, PapayaConstants.INDEX_NOT_FOUND (-1) if not found or null array input

lastIndexOf

public static int lastIndexOf(long[] array,
                              long valueToFind)

Finds the last index of the given value within the array.

This method returns PapayaConstants.INDEX_NOT_FOUND (-1) for a null input array.

Parameters:
array - the array to travers backwords looking for the object, may be null
valueToFind - the object to find
Returns:
the last index of the value within the array, PapayaConstants.INDEX_NOT_FOUND (-1) if not found or null array input

lastIndexOf

public static int lastIndexOf(long[] array,
                              long valueToFind,
                              int startIndex)

Finds the last index of the given value in the array starting at the given index.

This method returns PapayaConstants.INDEX_NOT_FOUND (-1) for a null input array.

A negative startIndex will return PapayaConstants.INDEX_NOT_FOUND (-1). A startIndex larger than the array length will search from the end of the array.

Parameters:
array - the array to traverse for looking for the object, may be null
valueToFind - the value to find
startIndex - the start index to travers backwards from
Returns:
the last index of the value within the array, PapayaConstants.INDEX_NOT_FOUND (-1) if not found or null array input

contains

public static boolean contains(long[] array,
                               long valueToFind)

Checks if the value is in the given array.

The method returns false if a null array is passed in.

Parameters:
array - the array to search through
valueToFind - the value to find
Returns:
true if the array contains the object

indicesWith

public static int[] indicesWith(long[] array,
                                long valueToFind)

Finds the indices containing the specified value in the array.

This method returns PapayaConstants.INDICES_NOT_FOUND (int[] = -1) for a null input array.

Parameters:
array - the array to search through for the value to find, may be null
valueToFind - the value to find
Returns:
the indices containing the value within the array, PapayaConstants.INDICES_NOT_FOUND (int[] = -1) if not found or null array input

indicesWith

public static int[] indicesWith(long[] array,
                                long valueToFind,
                                int startIndex)

Finds the indices containing the specified value in the array.

This method returns PapayaConstants.INDICES_NOT_FOUND (int[] = -1) for a null input array.

Parameters:
array - the array to search through for the value to find, may be null
valueToFind - the value to find
startIndex - the index to start searching at
Returns:
the indices containing the value within the array, PapayaConstants.INDICES_NOT_FOUND (int[] = -1) if not found or null array input

numRepeats

public static int numRepeats(long[] array,
                             long valueToFind)

Finds the number of times a given value/object is present in an array.

Parameters:
array - the array to search through for the value/object
valueToFind - the object to find.
Returns:
the number of times that value/object appears in the array PapayaConstants.INDEX_NOT_FOUND (-1) if not found or null array input

indexOf

public static int indexOf(int[] array,
                          int valueToFind)

Finds the index of the given value in the array.

This method returns PapayaConstants.INDEX_NOT_FOUND (-1) for a null input array.

Parameters:
array - the array to search through for the object, may be null
valueToFind - the value to find
Returns:
the index of the value within the array, PapayaConstants.INDEX_NOT_FOUND (-1) if not found or null array input

indexOf

public static int indexOf(int[] array,
                          int valueToFind,
                          int startIndex)

Finds the index of the given value in the array starting at the given index.

This method returns PapayaConstants.INDEX_NOT_FOUND (-1) for a null input array.

A negative startIndex is treated as zero. A startIndex larger than the array length will return PapayaConstants.INDEX_NOT_FOUND (-1).

Parameters:
array - the array to search through for the object, may be null
valueToFind - the value to find
startIndex - the index to start searching at
Returns:
the index of the value within the array, PapayaConstants.INDEX_NOT_FOUND (-1) if not found or null array input

lastIndexOf

public static int lastIndexOf(int[] array,
                              int valueToFind)

Finds the last index of the given value within the array.

This method returns PapayaConstants.INDEX_NOT_FOUND (-1) for a null input array.

Parameters:
array - the array to travers backwords looking for the object, may be null
valueToFind - the object to find
Returns:
the last index of the value within the array, PapayaConstants.INDEX_NOT_FOUND (-1) if not found or null array input

lastIndexOf

public static int lastIndexOf(int[] array,
                              int valueToFind,
                              int startIndex)

Finds the last index of the given value in the array starting at the given index.

This method returns PapayaConstants.INDEX_NOT_FOUND (-1) for a null input array.

A negative startIndex will return PapayaConstants.INDEX_NOT_FOUND (-1). A startIndex larger than the array length will search from the end of the array.

Parameters:
array - the array to traverse for looking for the object, may be null
valueToFind - the value to find
startIndex - the start index to travers backwards from
Returns:
the last index of the value within the array, PapayaConstants.INDEX_NOT_FOUND (-1) if not found or null array input

contains

public static boolean contains(int[] array,
                               int valueToFind)

Checks if the value is in the given array.

The method returns false if a null array is passed in.

Parameters:
array - the array to search through
valueToFind - the value to find
Returns:
true if the array contains the object

indicesWith

public static int[] indicesWith(int[] array,
                                int valueToFind)

Finds the indices containing the specified value in the array.

This method returns PapayaConstants.INDICES_NOT_FOUND (int[] = -1) for a null input array.

Parameters:
array - the array to search through for the value to find, may be null
valueToFind - the value to find
Returns:
the indices containing the value within the array, PapayaConstants.INDICES_NOT_FOUND (int[] = -1) if not found or null array input

indicesWith

public static int[] indicesWith(int[] array,
                                int valueToFind,
                                int startIndex)

Finds the indices containing the specified value in the array.

This method returns PapayaConstants.INDICES_NOT_FOUND (int[] = -1) for a null input array.

Parameters:
array - the array to search through for the value to find, may be null
valueToFind - the value to find
startIndex - the index to start searching at
Returns:
the indices containing the value within the array, PapayaConstants.INDICES_NOT_FOUND (int[] = -1) if not found or null array input

indicesWithin

public static int[] indicesWithin(int[] array,
                                  float minVal,
                                  float maxVal)

Finds the indices for the array elements within the min and max value (inclusive).

This method returns PapayaConstants.INDICES_NOT_FOUND (int[] = -1) for a null input array.


indicesLessThanOrEqualTo

public static int[] indicesLessThanOrEqualTo(int[] array,
                                             int valueOfMax)

indicesLessThan

public static int[] indicesLessThan(int[] array,
                                    int valueOfMax)

indicesGreaterThanOrEqualTo

public static int[] indicesGreaterThanOrEqualTo(int[] array,
                                                int valueOfMin)

indicesGreaterThan

public static int[] indicesGreaterThan(int[] array,
                                       int valueOfMin)

numRepeats

public static int numRepeats(int[] array,
                             int valueToFind)

Finds the number of times a given value/object is present in an array.

Parameters:
array - the array to search through for the value/object
valueToFind - the object to find.
Returns:
the number of times that value/object appears in the array PapayaConstants.INDEX_NOT_FOUND (-1) if not found or null array input

numLessThanOrEqualTo

public static int numLessThanOrEqualTo(int[] array,
                                       int valueOfMax)

Finds the number of elements less than or equal to the specified value.

Parameters:
array - the array to search through for the value/object
valueOfMax - the maximum value
Returns:
the number of elements ? that value

numLessThan

public static int numLessThan(int[] array,
                              int valueOfMax)

Finds the number of elements strictly less than the specified value.

Parameters:
array - the array to search through for the value/object
valueOfMax - the maximum value
Returns:
the number of elements strictly less than that value

numGreaterThanOrEqualTo

public static int numGreaterThanOrEqualTo(int[] array,
                                          int valueOfMin)

Finds the number of elements greater than or equal to the specified value.

Parameters:
array - the array to search through for the value/object
valueOfMax - the maximum value
Returns:
the number of elements ? that value

numGreaterThan

public static int numGreaterThan(int[] array,
                                 int valueOfMin)

Finds the number of elements strictly greater than the specified value.

Parameters:
array - the array to search through for the value/object
valueOfMax - the maximum value
Returns:
the number of elements strictly greater than that value

uniqueElems

public static int[] uniqueElems(int[] array)
Find the unique elements in a int array (uses HashSets)


indexOf

public static int indexOf(short[] array,
                          short valueToFind)

Finds the index of the given value in the array.

This method returns PapayaConstants.INDEX_NOT_FOUND (-1) for a null input array.

Parameters:
array - the array to search through for the object, may be null
valueToFind - the value to find
Returns:
the index of the value within the array, PapayaConstants.INDEX_NOT_FOUND (-1) if not found or null array input

indexOf

public static int indexOf(short[] array,
                          short valueToFind,
                          int startIndex)

Finds the index of the given value in the array starting at the given index.

This method returns PapayaConstants.INDEX_NOT_FOUND (-1) for a null input array.

A negative startIndex is treated as zero. A startIndex larger than the array length will return PapayaConstants.INDEX_NOT_FOUND (-1).

Parameters:
array - the array to search through for the object, may be null
valueToFind - the value to find
startIndex - the index to start searching at
Returns:
the index of the value within the array, PapayaConstants.INDEX_NOT_FOUND (-1) if not found or null array input

lastIndexOf

public static int lastIndexOf(short[] array,
                              short valueToFind)

Finds the last index of the given value within the array.

This method returns PapayaConstants.INDEX_NOT_FOUND (-1) for a null input array.

Parameters:
array - the array to travers backwords looking for the object, may be null
valueToFind - the object to find
Returns:
the last index of the value within the array, PapayaConstants.INDEX_NOT_FOUND (-1) if not found or null array input

lastIndexOf

public static int lastIndexOf(short[] array,
                              short valueToFind,
                              int startIndex)

Finds the last index of the given value in the array starting at the given index.

This method returns PapayaConstants.INDEX_NOT_FOUND (-1) for a null input array.

A negative startIndex will return PapayaConstants.INDEX_NOT_FOUND (-1). A startIndex larger than the array length will search from the end of the array.

Parameters:
array - the array to traverse for looking for the object, may be null
valueToFind - the value to find
startIndex - the start index to travers backwards from
Returns:
the last index of the value within the array, PapayaConstants.INDEX_NOT_FOUND (-1) if not found or null array input

contains

public static boolean contains(short[] array,
                               short valueToFind)

Checks if the value is in the given array.

The method returns false if a null array is passed in.

Parameters:
array - the array to search through
valueToFind - the value to find
Returns:
true if the array contains the object

indicesWith

public static int[] indicesWith(short[] array,
                                short valueToFind)

Finds the indices containing the specified value in the array.

This method returns PapayaConstants.INDICES_NOT_FOUND (int[] = -1) for a null input array.

Parameters:
array - the array to search through for the value to find, may be null
valueToFind - the value to find
Returns:
the indices containing the value within the array, PapayaConstants.INDICES_NOT_FOUND (int[] = -1) if not found or null array input

indicesWith

public static int[] indicesWith(short[] array,
                                short valueToFind,
                                int startIndex)

Finds the indices containing the specified value in the array.

This method returns PapayaConstants.INDICES_NOT_FOUND (int[] = -1) for a null input array.

Parameters:
array - the array to search through for the value to find, may be null
valueToFind - the value to find
startIndex - the index to start searching at
Returns:
the indices containing the value within the array, PapayaConstants.INDICES_NOT_FOUND (int[] = -1) if not found or null array input

numRepeats

public static int numRepeats(short[] array,
                             short valueToFind)

Finds the number of times a given value/object is present in an array.

Parameters:
array - the array to search through for the value/object
valueToFind - the object to find.
Returns:
the number of times that value/object appears in the array PapayaConstants.INDEX_NOT_FOUND (-1) if not found or null array input

indexOf

public static int indexOf(char[] array,
                          char valueToFind)

Finds the index of the given value in the array.

This method returns PapayaConstants.INDEX_NOT_FOUND (-1) for a null input array.

Parameters:
array - the array to search through for the object, may be null
valueToFind - the value to find
Returns:
the index of the value within the array, PapayaConstants.INDEX_NOT_FOUND (-1) if not found or null array input
Since:
2.1

indexOf

public static int indexOf(char[] array,
                          char valueToFind,
                          int startIndex)

Finds the index of the given value in the array starting at the given index.

This method returns PapayaConstants.INDEX_NOT_FOUND (-1) for a null input array.

A negative startIndex is treated as zero. A startIndex larger than the array length will return PapayaConstants.INDEX_NOT_FOUND (-1).

Parameters:
array - the array to search through for the object, may be null
valueToFind - the value to find
startIndex - the index to start searching at
Returns:
the index of the value within the array, PapayaConstants.INDEX_NOT_FOUND (-1) if not found or null array input
Since:
2.1

lastIndexOf

public static int lastIndexOf(char[] array,
                              char valueToFind)

Finds the last index of the given value within the array.

This method returns PapayaConstants.INDEX_NOT_FOUND (-1) for a null input array.

Parameters:
array - the array to travers backwords looking for the object, may be null
valueToFind - the object to find
Returns:
the last index of the value within the array, PapayaConstants.INDEX_NOT_FOUND (-1) if not found or null array input
Since:
2.1

lastIndexOf

public static int lastIndexOf(char[] array,
                              char valueToFind,
                              int startIndex)

Finds the last index of the given value in the array starting at the given index.

This method returns PapayaConstants.INDEX_NOT_FOUND (-1) for a null input array.

A negative startIndex will return PapayaConstants.INDEX_NOT_FOUND (-1). A startIndex larger than the array length will search from the end of the array.

Parameters:
array - the array to traverse for looking for the object, may be null
valueToFind - the value to find
startIndex - the start index to travers backwards from
Returns:
the last index of the value within the array, PapayaConstants.INDEX_NOT_FOUND (-1) if not found or null array input
Since:
2.1

contains

public static boolean contains(char[] array,
                               char valueToFind)

Checks if the value is in the given array.

The method returns false if a null array is passed in.

Parameters:
array - the array to search through
valueToFind - the value to find
Returns:
true if the array contains the object
Since:
2.1

indicesWith

public static int[] indicesWith(char[] array,
                                char valueToFind)

Finds the indices containing the specified value in the array.

This method returns PapayaConstants.INDICES_NOT_FOUND (int[] = -1) for a null input array.

Parameters:
array - the array to search through for the value to find, may be null
valueToFind - the value to find
Returns:
the indices containing the value within the array, PapayaConstants.INDICES_NOT_FOUND (int[] = -1) if not found or null array input

indicesWith

public static int[] indicesWith(char[] array,
                                char valueToFind,
                                int startIndex)

Finds the indices containing the specified value in the array.

This method returns PapayaConstants.INDICES_NOT_FOUND (int[] = -1) for a null input array.

Parameters:
array - the array to search through for the value to find, may be null
valueToFind - the value to find
startIndex - the index to start searching at
Returns:
the indices containing the value within the array, PapayaConstants.INDICES_NOT_FOUND (int[] = -1) if not found or null array input

numRepeats

public static int numRepeats(char[] array,
                             char valueToFind)

Finds the number of times a given value/object is present in an array.

Parameters:
array - the array to search through for the value/object
valueToFind - the object to find.
Returns:
the number of times that value/object appears in the array PapayaConstants.INDEX_NOT_FOUND (-1) if not found or null array input

indexOf

public static int indexOf(byte[] array,
                          byte valueToFind)

Finds the index of the given value in the array.

This method returns PapayaConstants.INDEX_NOT_FOUND (-1) for a null input array.

Parameters:
array - the array to search through for the object, may be null
valueToFind - the value to find
Returns:
the index of the value within the array, PapayaConstants.INDEX_NOT_FOUND (-1) if not found or null array input

indexOf

public static int indexOf(byte[] array,
                          byte valueToFind,
                          int startIndex)

Finds the index of the given value in the array starting at the given index.

This method returns PapayaConstants.INDEX_NOT_FOUND (-1) for a null input array.

A negative startIndex is treated as zero. A startIndex larger than the array length will return PapayaConstants.INDEX_NOT_FOUND (-1).

Parameters:
array - the array to search through for the object, may be null
valueToFind - the value to find
startIndex - the index to start searching at
Returns:
the index of the value within the array, PapayaConstants.INDEX_NOT_FOUND (-1) if not found or null array input

lastIndexOf

public static int lastIndexOf(byte[] array,
                              byte valueToFind)

Finds the last index of the given value within the array.

This method returns PapayaConstants.INDEX_NOT_FOUND (-1) for a null input array.

Parameters:
array - the array to travers backwords looking for the object, may be null
valueToFind - the object to find
Returns:
the last index of the value within the array, PapayaConstants.INDEX_NOT_FOUND (-1) if not found or null array input

lastIndexOf

public static int lastIndexOf(byte[] array,
                              byte valueToFind,
                              int startIndex)

Finds the last index of the given value in the array starting at the given index.

This method returns PapayaConstants.INDEX_NOT_FOUND (-1) for a null input array.

A negative startIndex will return PapayaConstants.INDEX_NOT_FOUND (-1). A startIndex larger than the array length will search from the end of the array.

Parameters:
array - the array to traverse for looking for the object, may be null
valueToFind - the value to find
startIndex - the start index to travers backwards from
Returns:
the last index of the value within the array, PapayaConstants.INDEX_NOT_FOUND (-1) if not found or null array input

contains

public static boolean contains(byte[] array,
                               byte valueToFind)

Checks if the value is in the given array.

The method returns false if a null array is passed in.

Parameters:
array - the array to search through
valueToFind - the value to find
Returns:
true if the array contains the object

indicesWith

public static int[] indicesWith(byte[] array,
                                byte valueToFind)

Finds the indices containing the specified value in the array.

This method returns PapayaConstants.INDICES_NOT_FOUND (int[] = -1) for a null input array.

Parameters:
array - the array to search through for the value to find, may be null
valueToFind - the value to find
Returns:
the indices containing the value within the array, PapayaConstants.INDICES_NOT_FOUND (int[] = -1) if not found or null array input

indicesWith

public static int[] indicesWith(byte[] array,
                                byte valueToFind,
                                int startIndex)

Finds the indices containing the specified value in the array.

This method returns PapayaConstants.INDICES_NOT_FOUND (int[] = -1) for a null input array.

Parameters:
array - the array to search through for the value to find, may be null
valueToFind - the value to find
startIndex - the index to start searching at
Returns:
the indices containing the value within the array, PapayaConstants.INDICES_NOT_FOUND (int[] = -1) if not found or null array input

numRepeats

public static int numRepeats(byte[] array,
                             byte valueToFind)

Finds the number of times a given value/object is present in an array.

Parameters:
array - the array to search through for the value/object
valueToFind - the object to find.
Returns:
the number of times that value/object appears in the array PapayaConstants.INDEX_NOT_FOUND (-1) if not found or null array input

indexOf

public static int indexOf(double[] array,
                          double valueToFind)

Finds the index of the given value in the array.

This method returns PapayaConstants.INDEX_NOT_FOUND (-1) for a null input array.

Parameters:
array - the array to search through for the object, may be null
valueToFind - the value to find
Returns:
the index of the value within the array, PapayaConstants.INDEX_NOT_FOUND (-1) if not found or null array input

indexOf

public static int indexOf(double[] array,
                          double valueToFind,
                          double tolerance)

Finds the index of the given value within a given tolerance in the array. This method will return the index of the first value which falls between the region defined by valueToFind - tolerance and valueToFind + tolerance.

This method returns PapayaConstants.INDEX_NOT_FOUND (-1) for a null input array.

Parameters:
array - the array to search through for the object, may be null
valueToFind - the value to find
tolerance - tolerance of the search
Returns:
the index of the value within the array, PapayaConstants.INDEX_NOT_FOUND (-1) if not found or null array input

indexOf

public static int indexOf(double[] array,
                          double valueToFind,
                          int startIndex)

Finds the index of the given value in the array starting at the given index.

This method returns PapayaConstants.INDEX_NOT_FOUND (-1) for a null input array.

A negative startIndex is treated as zero. A startIndex larger than the array length will return PapayaConstants.INDEX_NOT_FOUND (-1).

Parameters:
array - the array to search through for the object, may be null
valueToFind - the value to find
startIndex - the index to start searching at
Returns:
the index of the value within the array, PapayaConstants.INDEX_NOT_FOUND (-1) if not found or null array input

indexOf

public static int indexOf(double[] array,
                          double valueToFind,
                          int startIndex,
                          double tolerance)

Finds the index of the given value in the array starting at the given index. This method will return the index of the first value which falls between the region defined by valueToFind - tolerance and valueToFind + tolerance.

This method returns PapayaConstants.INDEX_NOT_FOUND (-1) for a null input array.

A negative startIndex is treated as zero. A startIndex larger than the array length will return PapayaConstants.INDEX_NOT_FOUND (-1).

Parameters:
array - the array to search through for the object, may be null
valueToFind - the value to find
startIndex - the index to start searching at
tolerance - tolerance of the search
Returns:
the index of the value within the array, PapayaConstants.INDEX_NOT_FOUND (-1) if not found or null array input

lastIndexOf

public static int lastIndexOf(double[] array,
                              double valueToFind)

Finds the last index of the given value within the array.

This method returns PapayaConstants.INDEX_NOT_FOUND (-1) for a null input array.

Parameters:
array - the array to travers backwords looking for the object, may be null
valueToFind - the object to find
Returns:
the last index of the value within the array, PapayaConstants.INDEX_NOT_FOUND (-1) if not found or null array input

lastIndexOf

public static int lastIndexOf(double[] array,
                              double valueToFind,
                              double tolerance)

Finds the last index of the given value within a given tolerance in the array. This method will return the index of the last value which falls between the region defined by valueToFind - tolerance and valueToFind + tolerance.

This method returns PapayaConstants.INDEX_NOT_FOUND (-1) for a null input array.

Parameters:
array - the array to search through for the object, may be null
valueToFind - the value to find
tolerance - tolerance of the search
Returns:
the index of the value within the array, PapayaConstants.INDEX_NOT_FOUND (-1) if not found or null array input

lastIndexOf

public static int lastIndexOf(double[] array,
                              double valueToFind,
                              int startIndex)

Finds the last index of the given value in the array starting at the given index.

This method returns PapayaConstants.INDEX_NOT_FOUND (-1) for a null input array.

A negative startIndex will return PapayaConstants.INDEX_NOT_FOUND (-1). A startIndex larger than the array length will search from the end of the array.

Parameters:
array - the array to traverse for looking for the object, may be null
valueToFind - the value to find
startIndex - the start index to travers backwards from
Returns:
the last index of the value within the array, PapayaConstants.INDEX_NOT_FOUND (-1) if not found or null array input

lastIndexOf

public static int lastIndexOf(double[] array,
                              double valueToFind,
                              int startIndex,
                              double tolerance)

Finds the last index of the given value in the array starting at the given index. This method will return the index of the last value which falls between the region defined by valueToFind - tolerance and valueToFind + tolerance.

This method returns PapayaConstants.INDEX_NOT_FOUND (-1) for a null input array.

A negative startIndex will return PapayaConstants.INDEX_NOT_FOUND (-1). A startIndex larger than the array length will search from the end of the array.

Parameters:
array - the array to traverse for looking for the object, may be null
valueToFind - the value to find
startIndex - the start index to travers backwards from
tolerance - search for value within plus/minus this amount
Returns:
the last index of the value within the array, PapayaConstants.INDEX_NOT_FOUND (-1) if not found or null array input

contains

public static boolean contains(double[] array,
                               double valueToFind)

Checks if the value is in the given array.

The method returns false if a null array is passed in.

Parameters:
array - the array to search through
valueToFind - the value to find
Returns:
true if the array contains the object

contains

public static boolean contains(double[] array,
                               double valueToFind,
                               double tolerance)

Checks if a value falling within the given tolerance is in the given array. If the array contains a value within the inclusive range defined by (value - tolerance) to (value + tolerance).

The method returns false if a null array is passed in.

Parameters:
array - the array to search
valueToFind - the value to find
tolerance - the array contains the tolerance of the search
Returns:
true if value falling within tolerance is in array

indicesWith

public static int[] indicesWith(double[] array,
                                double valueToFind)

Finds the indices containing the specified value in the array.

This method returns PapayaConstants.INDICES_NOT_FOUND (int[] = -1) for a null input array.

Parameters:
array - the array to search through for the value to find, may be null
valueToFind - the value to find
Returns:
the indices containing the value within the array, PapayaConstants.INDICES_NOT_FOUND (int[] = -1) if not found or null array input

indicesWith

public static int[] indicesWith(double[] array,
                                double valueToFind,
                                int startIndex)

Finds the indices containing the specified value in the array.

This method returns PapayaConstants.INDICES_NOT_FOUND (int[] = -1) for a null input array.

Parameters:
array - the array to search through for the value to find, may be null
valueToFind - the value to find
startIndex - the index to start searching at
Returns:
the indices containing the value within the array, PapayaConstants.INDICES_NOT_FOUND (int[] = -1) if not found or null array input

numRepeats

public static int numRepeats(double[] array,
                             double valueToFind)

Finds the number of times a given value/object is present in an array.

Parameters:
array - the array to search through for the value/object
valueToFind - the object to find.
Returns:
the number of times that value/object appears in the array PapayaConstants.INDEX_NOT_FOUND (-1) if not found or null array input

indexOf

public static int indexOf(float[] array,
                          float valueToFind)

Finds the index of the given value in the array.

This method returns PapayaConstants.INDEX_NOT_FOUND (-1) for a null input array.

Parameters:
array - the array to search through for the object, may be null
valueToFind - the value to find
Returns:
the index of the value within the array, PapayaConstants.INDEX_NOT_FOUND (-1) if not found or null array input

indexOf

public static int indexOf(float[] array,
                          float valueToFind,
                          int startIndex)

Finds the index of the given value in the array starting at the given index.

This method returns PapayaConstants.INDEX_NOT_FOUND (-1) for a null input array.

A negative startIndex is treated as zero. A startIndex larger than the array length will return PapayaConstants.INDEX_NOT_FOUND (-1).

Parameters:
array - the array to search through for the object, may be null
valueToFind - the value to find
startIndex - the index to start searching at
Returns:
the index of the value within the array, PapayaConstants.INDEX_NOT_FOUND (-1) if not found or null array input

lastIndexOf

public static int lastIndexOf(float[] array,
                              float valueToFind)

Finds the last index of the given value within the array.

This method returns PapayaConstants.INDEX_NOT_FOUND (-1) for a null input array.

Parameters:
array - the array to travers backwords looking for the object, may be null
valueToFind - the object to find
Returns:
the last index of the value within the array, PapayaConstants.INDEX_NOT_FOUND (-1) if not found or null array input

lastIndexOf

public static int lastIndexOf(float[] array,
                              float valueToFind,
                              int startIndex)

Finds the last index of the given value in the array starting at the given index.

This method returns PapayaConstants.INDEX_NOT_FOUND (-1) for a null input array.

A negative startIndex will return PapayaConstants.INDEX_NOT_FOUND (-1). A startIndex larger than the array length will search from the end of the array.

Parameters:
array - the array to traverse for looking for the object, may be null
valueToFind - the value to find
startIndex - the start index to travers backwards from
Returns:
the last index of the value within the array, PapayaConstants.INDEX_NOT_FOUND (-1) if not found or null array input

contains

public static boolean contains(float[] array,
                               float valueToFind)

Checks if the value is in the given array.

The method returns false if a null array is passed in.

Parameters:
array - the array to search through
valueToFind - the value to find
Returns:
true if the array contains the object

indicesWith

public static int[] indicesWith(float[] array,
                                float valueToFind)

Finds the indices containing the specified value in the array.

This method returns PapayaConstants.INDICES_NOT_FOUND (int[] = -1) for a null input array.

Parameters:
array - the array to search through for the value to find, may be null
valueToFind - the value to find
Returns:
the indices containing the value within the array, PapayaConstants.INDICES_NOT_FOUND (int[] = -1) if not found or null array input

indicesWith

public static int[] indicesWith(float[] array,
                                float valueToFind,
                                int startIndex)

Finds the indices containing the specified value in the array.

This method returns PapayaConstants.INDICES_NOT_FOUND (int[] = -1) for a null input array.

Parameters:
array - the array to search through for the value to find, may be null
valueToFind - the value to find
startIndex - the index to start searching at
Returns:
the indices containing the value within the array, PapayaConstants.INDICES_NOT_FOUND (int[] = -1) if not found or null array input

indicesWithin

public static int[] indicesWithin(float[] array,
                                  float minVal,
                                  float maxVal)

Finds the indices for the array elements within the min and max value (inclusive).

This method returns PapayaConstants.INDICES_NOT_FOUND (int[] = -1) for a null input array.


numRepeats

public static int numRepeats(float[] array,
                             float valueToFind)

Finds the number of times a given value/object is present in an array.

Parameters:
array - the array to search through for the value/object
valueToFind - the object to find.
Returns:
the number of times that value/object appears in the array PapayaConstants.INDEX_NOT_FOUND (-1) if not found or null array input

indicesLessThanOrEqualTo

public static int[] indicesLessThanOrEqualTo(float[] array,
                                             float valueOfMax)

indicesLessThan

public static int[] indicesLessThan(float[] array,
                                    float valueOfMax)

indicesGreaterThanOrEqualTo

public static int[] indicesGreaterThanOrEqualTo(float[] array,
                                                float valueOfMin)

indicesGreaterThan

public static int[] indicesGreaterThan(float[] array,
                                       float valueOfMin)

numLessThanOrEqualTo

public static int numLessThanOrEqualTo(float[] array,
                                       float valueOfMax)

Finds the number of elements less than or equal to the specified value.

Parameters:
array - the array to search through for the value/object
valueOfMax - the maximum value
Returns:
the number of elements ? that value

numLessThan

public static int numLessThan(float[] array,
                              float valueOfMax)

Finds the number of elements strictly less than the specified value.

Parameters:
array - the array to search through for the value/object
valueOfMax - the maximum value
Returns:
the number of elements strictly less than that value

numGreaterThanOrEqualTo

public static int numGreaterThanOrEqualTo(float[] array,
                                          float valueOfMin)

Finds the number of elements greater than or equal to the specified value.

Parameters:
array - the array to search through for the value/object
valueOfMax - the maximum value
Returns:
the number of elements ? that value

numGreaterThan

public static int numGreaterThan(float[] array,
                                 float valueOfMin)

Finds the number of elements strictly greater than the specified value.

Parameters:
array - the array to search through for the value/object
valueOfMax - the maximum value
Returns:
the number of elements strictly greater than that value

uniqueElems

public static float[] uniqueElems(float[] array)
Find the unique elements in a float array (uses HashSets)


indexOf

public static int indexOf(boolean[] array,
                          boolean valueToFind)

Finds the index of the given value in the array.

This method returns PapayaConstants.INDEX_NOT_FOUND (-1) for a null input array.

Parameters:
array - the array to search through for the object, may be null
valueToFind - the value to find
Returns:
the index of the value within the array, PapayaConstants.INDEX_NOT_FOUND (-1) if not found or null array input

indexOf

public static int indexOf(boolean[] array,
                          boolean valueToFind,
                          int startIndex)

Finds the index of the given value in the array starting at the given index.

This method returns PapayaConstants.INDEX_NOT_FOUND (-1) for a null input array.

A negative startIndex is treated as zero. A startIndex larger than the array length will return PapayaConstants.INDEX_NOT_FOUND (-1).

Parameters:
array - the array to search through for the object, may be null
valueToFind - the value to find
startIndex - the index to start searching at
Returns:
the index of the value within the array, PapayaConstants.INDEX_NOT_FOUND (-1) if not found or null array input

lastIndexOf

public static int lastIndexOf(boolean[] array,
                              boolean valueToFind)

Finds the last index of the given value within the array.

This method returns PapayaConstants.INDEX_NOT_FOUND (-1) if null array input.

Parameters:
array - the array to travers backwords looking for the object, may be null
valueToFind - the object to find
Returns:
the last index of the value within the array, PapayaConstants.INDEX_NOT_FOUND (-1) if not found or null array input

lastIndexOf

public static int lastIndexOf(boolean[] array,
                              boolean valueToFind,
                              int startIndex)

Finds the last index of the given value in the array starting at the given index.

This method returns PapayaConstants.INDEX_NOT_FOUND (-1) for a null input array.

A negative startIndex will return PapayaConstants.INDEX_NOT_FOUND (-1). A startIndex larger than the array length will search from the end of the array.

Parameters:
array - the array to traverse for looking for the object, may be null
valueToFind - the value to find
startIndex - the start index to travers backwards from
Returns:
the last index of the value within the array, PapayaConstants.INDEX_NOT_FOUND (-1) if not found or null array input

indicesWith

public static int[] indicesWith(boolean[] array,
                                boolean valueToFind)

Finds the indices containing the specified value in the array.

This method returns PapayaConstants.INDICES_NOT_FOUND (int[] = -1) for a null input array.

Parameters:
array - the array to search through for the value to find, may be null
valueToFind - the value to find
Returns:
the indices containing the value within the array, PapayaConstants.INDICES_NOT_FOUND (int[] = -1) if not found or null array input

indicesWith

public static int[] indicesWith(boolean[] array,
                                boolean valueToFind,
                                int startIndex)

Finds the indices containing the specified value in the array.

This method returns PapayaConstants.INDICES_NOT_FOUND (int[] = -1) for a null input array.

Parameters:
array - the array to search through for the value to find, may be null
valueToFind - the value to find
startIndex - the index to start searching at
Returns:
the indices containing the value within the array, PapayaConstants.INDICES_NOT_FOUND (int[] = -1) if not found or null array input

numRepeats

public static int numRepeats(boolean[] array,
                             boolean valueToFind)

Finds the number of times a given value/object is present in an array.

Parameters:
array - the array to search through for the value/object
valueToFind - the object to find.
Returns:
the number of times that value/object appears in the array PapayaConstants.INDEX_NOT_FOUND (-1) if not found or null array input


Processing library papaya by Adila Faruk. (C) 2014