JAPI 0.9.0
Yet another Java API
API Documentation

net.sf.japi.util
Class Arrays2

java.lang.Object
  extended by net.sf.japi.util.Arrays2

public final class Arrays2
extends Object

This class provides some additional utility methods you might miss in Arrays. It is named Arrays2 so you have no problems using both, this class and java.util.Arrays (no name conflict).

Author:
Christian Hujer
See Also:
Arrays

Method Summary
static int binarySearch(int[] a, int key, int low, int high)
          Searches the specified array of ints for the specified value using the binary search algorithm.
static boolean[] concat(boolean[]... a)
          Concatenate Arrays together.
static byte[] concat(byte[]... a)
          Concatenate Arrays together.
static char[] concat(char[]... a)
          Concatenate Arrays together.
static double[] concat(double[]... a)
          Concatenate Arrays together.
static float[] concat(float[]... a)
          Concatenate Arrays together.
static int[] concat(int[]... a)
          Concatenate Arrays together.
static long[] concat(long[]... a)
          Concatenate Arrays together.
static short[] concat(short[]... a)
          Concatenate Arrays together.
static
<T> T[]
concat(T[]... a)
          Concatenate Arrays together.
static
<T> int
count(Filter<? super T> filter, T... a)
          Count elements in an array that are accepted by the given filter.
static
<T> T[]
filter(Filter<? super T> filter, T... a)
          Returns an array only containing those elements accepted by the given filter.
static int freq(boolean[] array, boolean val)
          Count the frequency of a specific boolean in an unsorted array of booleans.
static int freq(boolean[] array, int fromIndex, int toIndex, boolean val)
          Count the frequency of a specific boolean in an unsorted array of booleans.
static int freq(byte[] array, byte val)
          Count the frequency of a specific byte in an unsorted array of bytes.
static int freq(byte[] array, int fromIndex, int toIndex, byte val)
          Count the frequency of a specific byte in an unsorted array of bytes.
static int freq(char[] array, char val)
          Count the frequency of a specific char in an unsorted array of chars.
static int freq(char[] array, int fromIndex, int toIndex, char val)
          Count the frequency of a specific char in an unsorted array of chars.
static int freq(double[] array, double val)
          Count the frequency of a specific double in an unsorted array of doubles.
static int freq(double[] array, int fromIndex, int toIndex, double val)
          Count the frequency of a specific double in an unsorted array of doubles.
static int freq(float[] array, float val)
          Count the frequency of a specific float in an unsorted array of floats.
static int freq(float[] array, int fromIndex, int toIndex, float val)
          Count the frequency of a specific float in an unsorted array of floats.
static int freq(int[] array, int val)
          Count the frequency of a specific int in an unsorted array of ints.
static int freq(int[] array, int fromIndex, int toIndex, int val)
          Count the frequency of a specific int in an unsorted array of ints.
static int freq(long[] array, int fromIndex, int toIndex, long val)
          Count the frequency of a specific long in an unsorted array of longs.
static int freq(long[] array, long val)
          Count the frequency of a specific long in an unsorted array of longs.
static int freq(short[] array, int fromIndex, int toIndex, short val)
          Count the frequency of a specific short in an unsorted array of shorts.
static int freq(short[] array, short val)
          Count the frequency of a specific short in an unsorted array of shorts.
static
<T extends Comparable<T>>
int
freqComparable(T[] array, int fromIndex, int toIndex, T val)
          Count the frequency of a specific Comparable in an unsorted array of Comparables.
static
<T extends Comparable<T>>
int
freqComparable(T[] array, T val)
          Count the frequency of a specific Comparable in an unsorted array of Comparables.
static
<T> int
freqComparator(T[] array, int fromIndex, int toIndex, T val, Comparator<? super T> comparator)
          Count the frequency of a specific Object in an unsorted array of Objects.
static
<T> int
freqComparator(T[] array, T val, Comparator<? super T> comparator)
          Count the frequency of a specific Object in an unsorted array of Objects.
static int freqEquals(Object[] array, int fromIndex, int toIndex, Object val)
          Count the frequency of a specific Object in an unsorted array of Objects.
static int freqEquals(Object[] array, Object val)
          Count the frequency of a specific Object in an unsorted array of Objects.
static int freqIdentity(Object[] array, int fromIndex, int toIndex, Object val)
          Count the frequency of a specific Object in an unsorted array of Objects.
static int freqIdentity(Object[] array, Object val)
          Count the frequency of a specific Object in an unsorted array of Objects.
static
<T> int
linearComparisonSearch(T o, int fromIndex, int toIndex, T[] data, Comparator<? super T> comp)
          Perform a linear search on an array of Objects.
static
<T> int
linearComparisonSearch(T o, T[] data, Comparator<? super T> comp)
          Perform a linear search on an array of Objects.
static int linearEqualitySearch(Object o, int fromIndex, int toIndex, Object[] data)
          Perform a linear search on an array of Objects.
static int linearEqualitySearch(Object o, Object[] data)
          Perform a linear search on an array of Objects.
static int linearIdentitySearch(Object o, int fromIndex, int toIndex, Object[] data)
          Perform a linear search on an array of Objects.
static int linearIdentitySearch(Object o, Object[] data)
          Perform a linear search on an array of Objects.
static int linearSearch(boolean z, boolean[] data)
          Perform a linear search on an array of booleans.
static int linearSearch(boolean z, int fromIndex, int toIndex, boolean[] data)
          Perform a linear search on an array of booleans.
static int linearSearch(byte b, byte[] data)
          Perform a linear search on an array of bytes.
static int linearSearch(byte b, int fromIndex, int toIndex, byte[] data)
          Perform a linear search on an array of bytes.
static int linearSearch(char c, char[] data)
          Perform a linear search on an array of chars.
static int linearSearch(char c, int fromIndex, int toIndex, char[] data)
          Perform a linear search on an array of chars.
static int linearSearch(double d, double[] data)
          Perform a linear search on an array of doubles.
static int linearSearch(double d, int fromIndex, int toIndex, double[] data)
          Perform a linear search on an array of doubles.
static int linearSearch(float f, float[] data)
          Perform a linear search on an array of floats.
static int linearSearch(float f, int fromIndex, int toIndex, float[] data)
          Perform a linear search on an array of floats.
static int linearSearch(int n, int[] data)
          Perform a linear search on an array of ints.
static int linearSearch(int n, int fromIndex, int toIndex, int[] data)
          Perform a linear search on an array of ints.
static int linearSearch(long l, int fromIndex, int toIndex, long[] data)
          Perform a linear search on an array of longs.
static int linearSearch(long l, long[] data)
          Perform a linear search on an array of longs.
static int linearSearch(short s, int fromIndex, int toIndex, short[] data)
          Perform a linear search on an array of shorts.
static int linearSearch(short s, short[] data)
          Perform a linear search on an array of shorts.
static void shuffle(boolean[] array)
          Shuffle an array of booleans.
static void shuffle(boolean[] array, int fromIndex, int toIndex)
          Shuffle an array of booleans.
static void shuffle(boolean[] array, int fromIndex, int toIndex, Random rnd)
          Shuffle an array of booleans.
static void shuffle(boolean[] array, Random rnd)
          Shuffle an array of booleans.
static void shuffle(byte[] array)
          Shuffle an array of bytes.
static void shuffle(byte[] array, int fromIndex, int toIndex)
          Shuffle an array of bytes.
static void shuffle(byte[] array, int fromIndex, int toIndex, Random rnd)
          Shuffle an array of bytes.
static void shuffle(byte[] array, Random rnd)
          Shuffle an array of bytes.
static void shuffle(char[] array)
          Shuffle an array of chars.
static void shuffle(char[] array, int fromIndex, int toIndex)
          Shuffle an array of chars.
static void shuffle(char[] array, int fromIndex, int toIndex, Random rnd)
          Shuffle an array of chars.
static void shuffle(char[] array, Random rnd)
          Shuffle an array of chars.
static void shuffle(double[] array)
          Shuffle an array of doubles.
static void shuffle(double[] array, int fromIndex, int toIndex)
          Shuffle an array of doubles.
static void shuffle(double[] array, int fromIndex, int toIndex, Random rnd)
          Shuffle an array of doubles.
static void shuffle(double[] array, Random rnd)
          Shuffle an array of doubles.
static void shuffle(float[] array)
          Shuffle an array of floats.
static void shuffle(float[] array, int fromIndex, int toIndex)
          Shuffle an array of floats.
static void shuffle(float[] array, int fromIndex, int toIndex, Random rnd)
          Shuffle an array of floats.
static void shuffle(float[] array, Random rnd)
          Shuffle an array of floats.
static void shuffle(int[] array)
          Shuffle an array of ints.
static void shuffle(int[] array, int fromIndex, int toIndex)
          Shuffle an array of ints.
static void shuffle(int[] array, int fromIndex, int toIndex, Random rnd)
          Shuffle an array of ints.
static void shuffle(int[] array, Random rnd)
          Shuffle an array of ints.
static void shuffle(long[] array)
          Shuffle an array of longs.
static void shuffle(long[] array, int fromIndex, int toIndex)
          Shuffle an array of longs.
static void shuffle(long[] array, int fromIndex, int toIndex, Random rnd)
          Shuffle an array of longs.
static void shuffle(long[] array, Random rnd)
          Shuffle an array of longs.
static void shuffle(Object[] array)
          Shuffle an array of Objects.
static void shuffle(Object[] array, int fromIndex, int toIndex)
          Shuffle an array of Objects.
static void shuffle(Object[] array, int fromIndex, int toIndex, Random rnd)
          Shuffle an array of Objects.
static void shuffle(Object[] array, Random rnd)
          Shuffle an array of Objects.
static void shuffle(short[] array)
          Shuffle an array of shorts.
static void shuffle(short[] array, int fromIndex, int toIndex)
          Shuffle an array of shorts.
static void shuffle(short[] array, int fromIndex, int toIndex, Random rnd)
          Shuffle an array of shorts.
static void shuffle(short[] array, Random rnd)
          Shuffle an array of shorts.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

concat

public static double[] concat(double[]... a)
Concatenate Arrays together.

Parameters:
a - Arrays to concatenate
Returns:
new Array containing all elements of all arrays

concat

public static float[] concat(float[]... a)
Concatenate Arrays together.

Parameters:
a - Arrays to concatenate
Returns:
new Array containing all elements of all arrays

concat

public static long[] concat(long[]... a)
Concatenate Arrays together.

Parameters:
a - Arrays to concatenate
Returns:
new Array containing all elements of all arrays

concat

public static int[] concat(int[]... a)
Concatenate Arrays together.

Parameters:
a - Arrays to concatenate
Returns:
new Array containing all elements of all arrays

concat

public static short[] concat(short[]... a)
Concatenate Arrays together.

Parameters:
a - Arrays to concatenate
Returns:
new Array containing all elements of all arrays

concat

public static char[] concat(char[]... a)
Concatenate Arrays together.

Parameters:
a - Arrays to concatenate
Returns:
new Array containing all elements of all arrays

concat

public static byte[] concat(byte[]... a)
Concatenate Arrays together.

Parameters:
a - Arrays to concatenate
Returns:
new Array containing all elements of all arrays

concat

public static boolean[] concat(boolean[]... a)
Concatenate Arrays together.

Parameters:
a - Arrays to concatenate
Returns:
new Array containing all elements of all arrays

concat

public static <T> T[] concat(T[]... a)
Concatenate Arrays together.

Parameters:
a - Arrays to concatenate
Returns:
new Array containing all elements of all arrays

filter

public static <T> T[] filter(Filter<? super T> filter,
                             T... a)
Returns an array only containing those elements accepted by the given filter. The original array remains unmodified.

Parameters:
a - Elements to filter
filter - Filter to use for a
Returns:
array containing only those elements from a accepted by filter
See Also:
Collections2.filter(Collection,Filter)

count

public static <T> int count(Filter<? super T> filter,
                            T... a)
Count elements in an array that are accepted by the given filter.

Parameters:
a - Elements to count in
filter - Filter to use for a
Returns:
number of elements in a accepted by filter

binarySearch

public static int binarySearch(int[] a,
                               int key,
                               int low,
                               int high)
Searches the specified array of ints for the specified value using the binary search algorithm. The array must be sorted (as by the sort method, above) prior to making this call. If it is not sorted, the results are undefined (even a runtime exception might occur). If the array contains multiple elements with the specified value, there is no guarantee which one will be found.

Parameters:
a - the array to be searched.
key - the value to be searched for.
low - lower border (must be >= 0)
high - upper border (must be < a.length)
Returns:
index of the search key, if it is contained in the list; otherwise, (-(insertion point) - 1). The insertion point is defined as the point at which the key would be inserted into the list: the index of the first element greater than the key, or list.size(), if all elements in the list are less than the specified key. Note that this guarantees that the return value will be >= 0 if and only if the key is found.
Throws:
ArrayIndexOutOfBoundsException - if low < 0 or high >= a.length
See Also:
Arrays.binarySearch(int[],int), Arrays.sort(int[])

linearSearch

public static int linearSearch(boolean z,
                               boolean[] data)
Perform a linear search on an array of booleans.

Parameters:
z - boolean to find in data
data - array of booleans to perform linear search on
Returns:
index of n in data or -1 if not found

linearSearch

public static int linearSearch(char c,
                               char[] data)
Perform a linear search on an array of chars.

Parameters:
c - char to find in data
data - array of chars to perform linear search on
Returns:
index of n in data or -1 if not found

linearSearch

public static int linearSearch(double d,
                               double[] data)
Perform a linear search on an array of doubles.

Parameters:
d - double to find in data
data - array of doubles to perform linear search on
Returns:
index of n in data or -1 if not found

linearSearch

public static int linearSearch(float f,
                               float[] data)
Perform a linear search on an array of floats.

Parameters:
f - float to find in data
data - array of floats to perform linear search on
Returns:
index of n in data or -1 if not found

linearSearch

public static int linearSearch(long l,
                               long[] data)
Perform a linear search on an array of longs.

Parameters:
l - long to find in data
data - array of longs to perform linear search on
Returns:
index of n in data or -1 if not found

linearSearch

public static int linearSearch(int n,
                               int[] data)
Perform a linear search on an array of ints.

Parameters:
n - int to find in data
data - array of ints to perform linear search on
Returns:
index of n in data or -1 if not found

linearSearch

public static int linearSearch(short s,
                               short[] data)
Perform a linear search on an array of shorts.

Parameters:
s - short to find in data
data - array of shorts to perform linear search on
Returns:
index of n in data or -1 if not found

linearSearch

public static int linearSearch(byte b,
                               byte[] data)
Perform a linear search on an array of bytes.

Parameters:
b - byte to find in data
data - array of bytes to perform linear search on
Returns:
index of n in data or -1 if not found

linearSearch

public static int linearSearch(boolean z,
                               int fromIndex,
                               int toIndex,
                               boolean[] data)
Perform a linear search on an array of booleans.

Parameters:
z - boolean to find in data
fromIndex - start index within data
toIndex - end index within data
data - array of booleans to perform linear search on
Returns:
index of n in data or -1 if not found
Throws:
ArrayIndexOutOfBoundsException - in case fromIndex < 0 or toIndex >= data.length

linearSearch

public static int linearSearch(char c,
                               int fromIndex,
                               int toIndex,
                               char[] data)
Perform a linear search on an array of chars.

Parameters:
c - char to find in data
fromIndex - start index within data
toIndex - end index within data
data - array of chars to perform linear search on
Returns:
index of n in data or -1 if not found
Throws:
ArrayIndexOutOfBoundsException - in case fromIndex < 0 or toIndex >= data.length

linearSearch

public static int linearSearch(double d,
                               int fromIndex,
                               int toIndex,
                               double[] data)
Perform a linear search on an array of doubles.

Parameters:
d - double to find in data
fromIndex - start index within data
toIndex - end index within data
data - array of doubles to perform linear search on
Returns:
index of n in data or -1 if not found
Throws:
ArrayIndexOutOfBoundsException - in case fromIndex < 0 or toIndex >= data.length

linearSearch

public static int linearSearch(float f,
                               int fromIndex,
                               int toIndex,
                               float[] data)
Perform a linear search on an array of floats.

Parameters:
f - float to find in data
fromIndex - start index within data
toIndex - end index within data
data - array of floats to perform linear search on
Returns:
index of n in data or -1 if not found
Throws:
ArrayIndexOutOfBoundsException - in case fromIndex < 0 or toIndex >= data.length

linearSearch

public static int linearSearch(long l,
                               int fromIndex,
                               int toIndex,
                               long[] data)
Perform a linear search on an array of longs.

Parameters:
l - long to find in data
fromIndex - start index within data
toIndex - end index within data
data - array of longs to perform linear search on
Returns:
index of n in data or -1 if not found
Throws:
ArrayIndexOutOfBoundsException - in case fromIndex < 0 or toIndex >= data.length

linearSearch

public static int linearSearch(int n,
                               int fromIndex,
                               int toIndex,
                               int[] data)
Perform a linear search on an array of ints.

Parameters:
n - int to find in data
fromIndex - start index within data
toIndex - end index within data
data - array of ints to perform linear search on
Returns:
index of n in data or -1 if not found
Throws:
ArrayIndexOutOfBoundsException - in case fromIndex < 0 or toIndex >= data.length

linearSearch

public static int linearSearch(short s,
                               int fromIndex,
                               int toIndex,
                               short[] data)
Perform a linear search on an array of shorts.

Parameters:
s - short to find in data
fromIndex - start index within data
toIndex - end index within data
data - array of shorts to perform linear search on
Returns:
index of n in data or -1 if not found
Throws:
ArrayIndexOutOfBoundsException - in case fromIndex < 0 or toIndex >= data.length

linearSearch

public static int linearSearch(byte b,
                               int fromIndex,
                               int toIndex,
                               byte[] data)
Perform a linear search on an array of bytes.

Parameters:
b - byte to find in data
fromIndex - start index within data
toIndex - end index within data
data - array of bytes to perform linear search on
Returns:
index of n in data or -1 if not found
Throws:
ArrayIndexOutOfBoundsException - in case fromIndex < 0 or toIndex >= data.length

linearIdentitySearch

public static int linearIdentitySearch(Object o,
                                       Object[] data)
Perform a linear search on an array of Objects.

Parameters:
o - Object to find in data
data - array of Objects to perform linear search on
Returns:
index of n in data or -1 if not found

linearIdentitySearch

public static int linearIdentitySearch(Object o,
                                       int fromIndex,
                                       int toIndex,
                                       Object[] data)
Perform a linear search on an array of Objects.

Parameters:
o - Object to find in data
fromIndex - start index within data
toIndex - end index within data
data - array of Objects to perform linear search on
Returns:
index of n in data or -1 if not found
Throws:
ArrayIndexOutOfBoundsException - in case fromIndex < 0 or toIndex >= data.length

linearEqualitySearch

public static int linearEqualitySearch(Object o,
                                       Object[] data)
Perform a linear search on an array of Objects.

Parameters:
o - Object to find in data
data - array of Objects to perform linear search on
Returns:
index of n in data or -1 if not found

linearEqualitySearch

public static int linearEqualitySearch(Object o,
                                       int fromIndex,
                                       int toIndex,
                                       Object[] data)
Perform a linear search on an array of Objects.

Parameters:
o - Object to find in data
fromIndex - start index within data
toIndex - end index within data
data - array of Objects to perform linear search on
Returns:
index of n in data or -1 if not found
Throws:
ArrayIndexOutOfBoundsException - in case fromIndex < 0 or toIndex >= data.length

linearComparisonSearch

public static <T> int linearComparisonSearch(T o,
                                             T[] data,
                                             Comparator<? super T> comp)
Perform a linear search on an array of Objects.

Parameters:
o - Object to find in data
data - array of Objects to perform linear search on
Returns:
index of n in data or -1 if not found

linearComparisonSearch

public static <T> int linearComparisonSearch(T o,
                                             int fromIndex,
                                             int toIndex,
                                             T[] data,
                                             Comparator<? super T> comp)
Perform a linear search on an array of Objects.

Parameters:
o - Object to find in data
fromIndex - start index within data
toIndex - end index within data
data - array of Objects to perform linear search on
Returns:
index of n in data or -1 if not found
Throws:
ArrayIndexOutOfBoundsException - in case fromIndex < 0 or toIndex >= data.length

shuffle

public static void shuffle(boolean[] array)
Shuffle an array of booleans.

Parameters:
array - Array to shuffle

shuffle

public static void shuffle(boolean[] array,
                           Random rnd)
Shuffle an array of booleans.

Parameters:
array - Array to shuffle
rnd - Random Number Generator

shuffle

public static void shuffle(boolean[] array,
                           int fromIndex,
                           int toIndex)
Shuffle an array of booleans.

Parameters:
array - Array to shuffle
fromIndex - Start index to shuffle at (inclusive)
toIndex - End index to shuffle at (exclusive)

shuffle

public static void shuffle(boolean[] array,
                           int fromIndex,
                           int toIndex,
                           Random rnd)
Shuffle an array of booleans.

Parameters:
array - Array to shuffle
fromIndex - Start index to shuffle at (inclusive)
toIndex - End index to shuffle at (exclusive)
rnd - Random number generator

shuffle

public static void shuffle(char[] array)
Shuffle an array of chars.

Parameters:
array - Array to shuffle

shuffle

public static void shuffle(char[] array,
                           Random rnd)
Shuffle an array of chars.

Parameters:
array - Array to shuffle
rnd - Random Number Generator

shuffle

public static void shuffle(char[] array,
                           int fromIndex,
                           int toIndex)
Shuffle an array of chars.

Parameters:
array - Array to shuffle
fromIndex - Start index to shuffle at (inclusive)
toIndex - End index to shuffle at (exclusive)

shuffle

public static void shuffle(char[] array,
                           int fromIndex,
                           int toIndex,
                           Random rnd)
Shuffle an array of chars.

Parameters:
array - Array to shuffle
fromIndex - Start index to shuffle at (inclusive)
toIndex - End index to shuffle at (exclusive)
rnd - Random number generator

shuffle

public static void shuffle(byte[] array)
Shuffle an array of bytes.

Parameters:
array - Array to shuffle

shuffle

public static void shuffle(byte[] array,
                           Random rnd)
Shuffle an array of bytes.

Parameters:
array - Array to shuffle
rnd - Random Number Generator

shuffle

public static void shuffle(byte[] array,
                           int fromIndex,
                           int toIndex)
Shuffle an array of bytes.

Parameters:
array - Array to shuffle
fromIndex - Start index to shuffle at (inclusive)
toIndex - End index to shuffle at (exclusive)

shuffle

public static void shuffle(byte[] array,
                           int fromIndex,
                           int toIndex,
                           Random rnd)
Shuffle an array of bytes.

Parameters:
array - Array to shuffle
fromIndex - Start index to shuffle at (inclusive)
toIndex - End index to shuffle at (exclusive)
rnd - Random number generator

shuffle

public static void shuffle(short[] array)
Shuffle an array of shorts.

Parameters:
array - Array to shuffle

shuffle

public static void shuffle(short[] array,
                           Random rnd)
Shuffle an array of shorts.

Parameters:
array - Array to shuffle
rnd - Random Number Generator

shuffle

public static void shuffle(short[] array,
                           int fromIndex,
                           int toIndex)
Shuffle an array of shorts.

Parameters:
array - Array to shuffle
fromIndex - Start index to shuffle at (inclusive)
toIndex - End index to shuffle at (exclusive)

shuffle

public static void shuffle(short[] array,
                           int fromIndex,
                           int toIndex,
                           Random rnd)
Shuffle an array of shorts.

Parameters:
array - Array to shuffle
fromIndex - Start index to shuffle at (inclusive)
toIndex - End index to shuffle at (exclusive)
rnd - Random number generator

shuffle

public static void shuffle(int[] array)
Shuffle an array of ints.

Parameters:
array - Array to shuffle

shuffle

public static void shuffle(int[] array,
                           Random rnd)
Shuffle an array of ints.

Parameters:
array - Array to shuffle
rnd - Random Number Generator

shuffle

public static void shuffle(int[] array,
                           int fromIndex,
                           int toIndex)
Shuffle an array of ints.

Parameters:
array - Array to shuffle
fromIndex - Start index to shuffle at (inclusive)
toIndex - End index to shuffle at (exclusive)

shuffle

public static void shuffle(int[] array,
                           int fromIndex,
                           int toIndex,
                           Random rnd)
Shuffle an array of ints.

Parameters:
array - Array to shuffle
fromIndex - Start index to shuffle at (inclusive)
toIndex - End index to shuffle at (exclusive)
rnd - Random number generator

shuffle

public static void shuffle(long[] array)
Shuffle an array of longs.

Parameters:
array - Array to shuffle

shuffle

public static void shuffle(long[] array,
                           Random rnd)
Shuffle an array of longs.

Parameters:
array - Array to shuffle
rnd - Random Number Generator

shuffle

public static void shuffle(long[] array,
                           int fromIndex,
                           int toIndex)
Shuffle an array of longs.

Parameters:
array - Array to shuffle
fromIndex - Start index to shuffle at (inclusive)
toIndex - End index to shuffle at (exclusive)

shuffle

public static void shuffle(long[] array,
                           int fromIndex,
                           int toIndex,
                           Random rnd)
Shuffle an array of longs.

Parameters:
array - Array to shuffle
fromIndex - Start index to shuffle at (inclusive)
toIndex - End index to shuffle at (exclusive)
rnd - Random number generator

shuffle

public static void shuffle(float[] array)
Shuffle an array of floats.

Parameters:
array - Array to shuffle

shuffle

public static void shuffle(float[] array,
                           Random rnd)
Shuffle an array of floats.

Parameters:
array - Array to shuffle
rnd - Random Number Generator

shuffle

public static void shuffle(float[] array,
                           int fromIndex,
                           int toIndex)
Shuffle an array of floats.

Parameters:
array - Array to shuffle
fromIndex - Start index to shuffle at (inclusive)
toIndex - End index to shuffle at (exclusive)

shuffle

public static void shuffle(float[] array,
                           int fromIndex,
                           int toIndex,
                           Random rnd)
Shuffle an array of floats.

Parameters:
array - Array to shuffle
fromIndex - Start index to shuffle at (inclusive)
toIndex - End index to shuffle at (exclusive)
rnd - Random number generator

shuffle

public static void shuffle(double[] array)
Shuffle an array of doubles.

Parameters:
array - Array to shuffle

shuffle

public static void shuffle(double[] array,
                           Random rnd)
Shuffle an array of doubles.

Parameters:
array - Array to shuffle
rnd - Random Number Generator

shuffle

public static void shuffle(double[] array,
                           int fromIndex,
                           int toIndex)
Shuffle an array of doubles.

Parameters:
array - Array to shuffle
fromIndex - Start index to shuffle at (inclusive)
toIndex - End index to shuffle at (exclusive)

shuffle

public static void shuffle(double[] array,
                           int fromIndex,
                           int toIndex,
                           Random rnd)
Shuffle an array of doubles.

Parameters:
array - Array to shuffle
fromIndex - Start index to shuffle at (inclusive)
toIndex - End index to shuffle at (exclusive)
rnd - Random number generator

shuffle

public static void shuffle(Object[] array)
Shuffle an array of Objects.

Parameters:
array - Array to shuffle

shuffle

public static void shuffle(Object[] array,
                           Random rnd)
Shuffle an array of Objects.

Parameters:
array - Array to shuffle
rnd - Random Number Generator

shuffle

public static void shuffle(Object[] array,
                           int fromIndex,
                           int toIndex)
Shuffle an array of Objects.

Parameters:
array - Array to shuffle
fromIndex - Start index to shuffle at (inclusive)
toIndex - End index to shuffle at (exclusive)

shuffle

public static void shuffle(Object[] array,
                           int fromIndex,
                           int toIndex,
                           Random rnd)
Shuffle an array of Objects.

Parameters:
array - Array to shuffle
fromIndex - Start index to shuffle at (inclusive)
toIndex - End index to shuffle at (exclusive)
rnd - Random number generator

freq

public static int freq(boolean[] array,
                       boolean val)
Count the frequency of a specific boolean in an unsorted array of booleans.

Parameters:
array - Array of booleans to count in
val - boolean value to count frequency of
Returns:
frequency of val in array

freq

public static int freq(boolean[] array,
                       int fromIndex,
                       int toIndex,
                       boolean val)
Count the frequency of a specific boolean in an unsorted array of booleans.

Parameters:
array - Array of booleans to count in
fromIndex - Start index to shuffle at (inclusive)
toIndex - End index to shuffle at (exclusive)
val - boolean value to count frequency of
Returns:
frequency of val in array between fromIndex and toIndex

freq

public static int freq(char[] array,
                       char val)
Count the frequency of a specific char in an unsorted array of chars.

Parameters:
array - Array of chars to count in
val - char value to count frequency of
Returns:
frequency of val in array

freq

public static int freq(char[] array,
                       int fromIndex,
                       int toIndex,
                       char val)
Count the frequency of a specific char in an unsorted array of chars.

Parameters:
array - Array of chars to count in
fromIndex - Start index to shuffle at (inclusive)
toIndex - End index to shuffle at (exclusive)
val - char value to count frequency of
Returns:
frequency of val in array between fromIndex and toIndex

freq

public static int freq(byte[] array,
                       byte val)
Count the frequency of a specific byte in an unsorted array of bytes.

Parameters:
array - Array of bytes to count in
val - byte value to count frequency of
Returns:
frequency of val in array

freq

public static int freq(byte[] array,
                       int fromIndex,
                       int toIndex,
                       byte val)
Count the frequency of a specific byte in an unsorted array of bytes.

Parameters:
array - Array of bytes to count in
fromIndex - Start index to shuffle at (inclusive)
toIndex - End index to shuffle at (exclusive)
val - byte value to count frequency of
Returns:
frequency of val in array between fromIndex and toIndex

freq

public static int freq(short[] array,
                       short val)
Count the frequency of a specific short in an unsorted array of shorts.

Parameters:
array - Array of shorts to count in
val - short value to count frequency of
Returns:
frequency of val in array

freq

public static int freq(short[] array,
                       int fromIndex,
                       int toIndex,
                       short val)
Count the frequency of a specific short in an unsorted array of shorts.

Parameters:
array - Array of shorts to count in
fromIndex - Start index to shuffle at (inclusive)
toIndex - End index to shuffle at (exclusive)
val - short value to count frequency of
Returns:
frequency of val in array between fromIndex and toIndex

freq

public static int freq(int[] array,
                       int val)
Count the frequency of a specific int in an unsorted array of ints.

Parameters:
array - Array of ints to count in
val - int value to count frequency of
Returns:
frequency of val in array

freq

public static int freq(int[] array,
                       int fromIndex,
                       int toIndex,
                       int val)
Count the frequency of a specific int in an unsorted array of ints.

Parameters:
array - Array of ints to count in
fromIndex - Start index to shuffle at (inclusive)
toIndex - End index to shuffle at (exclusive)
val - int value to count frequency of
Returns:
frequency of val in array between fromIndex and toIndex

freq

public static int freq(long[] array,
                       long val)
Count the frequency of a specific long in an unsorted array of longs.

Parameters:
array - Array of longs to count in
val - long value to count frequency of
Returns:
frequency of val in array

freq

public static int freq(long[] array,
                       int fromIndex,
                       int toIndex,
                       long val)
Count the frequency of a specific long in an unsorted array of longs.

Parameters:
array - Array of longs to count in
fromIndex - Start index to shuffle at (inclusive)
toIndex - End index to shuffle at (exclusive)
val - long value to count frequency of
Returns:
frequency of val in array between fromIndex and toIndex

freq

public static int freq(float[] array,
                       float val)
Count the frequency of a specific float in an unsorted array of floats.

Parameters:
array - Array of floats to count in
val - float value to count frequency of
Returns:
frequency of val in array

freq

public static int freq(float[] array,
                       int fromIndex,
                       int toIndex,
                       float val)
Count the frequency of a specific float in an unsorted array of floats.

Parameters:
array - Array of floats to count in
fromIndex - Start index to shuffle at (inclusive)
toIndex - End index to shuffle at (exclusive)
val - float value to count frequency of
Returns:
frequency of val in array between fromIndex and toIndex

freq

public static int freq(double[] array,
                       double val)
Count the frequency of a specific double in an unsorted array of doubles.

Parameters:
array - Array of doubles to count in
val - double value to count frequency of
Returns:
frequency of val in array

freq

public static int freq(double[] array,
                       int fromIndex,
                       int toIndex,
                       double val)
Count the frequency of a specific double in an unsorted array of doubles.

Parameters:
array - Array of doubles to count in
fromIndex - Start index to shuffle at (inclusive)
toIndex - End index to shuffle at (exclusive)
val - double value to count frequency of
Returns:
frequency of val in array between fromIndex and toIndex

freqIdentity

public static int freqIdentity(Object[] array,
                               Object val)
Count the frequency of a specific Object in an unsorted array of Objects.

Parameters:
array - Array of Objects to count in
val - Object value to count frequency of
Returns:
frequency of val in array

freqIdentity

public static int freqIdentity(Object[] array,
                               int fromIndex,
                               int toIndex,
                               Object val)
Count the frequency of a specific Object in an unsorted array of Objects.

Parameters:
array - Array of Objects to count in
fromIndex - Start index to shuffle at (inclusive)
toIndex - End index to shuffle at (exclusive)
val - Object value to count frequency of
Returns:
frequency of val in array between fromIndex and toIndex

freqEquals

public static int freqEquals(Object[] array,
                             Object val)
Count the frequency of a specific Object in an unsorted array of Objects.

Parameters:
array - Array of Objects to count in
val - Object value to count frequency of
Returns:
frequency of val in array

freqEquals

public static int freqEquals(Object[] array,
                             int fromIndex,
                             int toIndex,
                             Object val)
Count the frequency of a specific Object in an unsorted array of Objects.

Parameters:
array - Array of Objects to count in
fromIndex - Start index to shuffle at (inclusive)
toIndex - End index to shuffle at (exclusive)
val - Object value to count frequency of
Returns:
frequency of val in array between fromIndex and toIndex

freqComparable

public static <T extends Comparable<T>> int freqComparable(T[] array,
                                                           T val)
Count the frequency of a specific Comparable in an unsorted array of Comparables.

Parameters:
array - Array of Comparables to count in
val - Comparable value to count frequency of
Returns:
frequency of val in array

freqComparable

public static <T extends Comparable<T>> int freqComparable(T[] array,
                                                           int fromIndex,
                                                           int toIndex,
                                                           T val)
Count the frequency of a specific Comparable in an unsorted array of Comparables.

Parameters:
array - Array of Comparables to count in
fromIndex - Start index to shuffle at (inclusive)
toIndex - End index to shuffle at (exclusive)
val - Comparable value to count frequency of
Returns:
frequency of val in array between fromIndex and toIndex

freqComparator

public static <T> int freqComparator(T[] array,
                                     T val,
                                     Comparator<? super T> comparator)
Count the frequency of a specific Object in an unsorted array of Objects.

Parameters:
array - Array of Objects to count in
val - Object value to count frequency of
comparator - Comparator for comparing objects
Returns:
frequency of val in array

freqComparator

public static <T> int freqComparator(T[] array,
                                     int fromIndex,
                                     int toIndex,
                                     T val,
                                     Comparator<? super T> comparator)
Count the frequency of a specific Object in an unsorted array of Objects.

Parameters:
array - Array of Objects to count in
fromIndex - Start index to shuffle at (inclusive)
toIndex - End index to shuffle at (exclusive)
val - Object value to count frequency of
comparator - Comparator for comparing objects
Returns:
frequency of val in array between fromIndex and toIndex

JAPI
Yet another Java API
API Documentation

© 2005-2006 Christian Hujer. All rights reserved. See copyright