Package net.dermetfan.utils
Class ArrayUtils
java.lang.Object
net.dermetfan.utils.ArrayUtils
- Direct Known Subclasses:
- ArrayUtils
public class ArrayUtils
extends java.lang.Object
array utility methods
- 
Constructor SummaryConstructors Constructor Description ArrayUtils()
- 
Method SummaryModifier and Type Method Description static java.lang.Boolean[]box(boolean[] values)static java.lang.Float[]box(float[] values)static java.lang.Integer[]box(int[] values)static voidcheckRegion(float[] array, int offset, int length)static voidcheckRegion(int[] array, int offset, int length)static voidcheckRegion(java.lang.Object[] array, int offset, int length)static <T, T2 extends T>
 booleancontains(T[] array, T2[] other, boolean identity)static <T> booleancontains(T[] array, T value, boolean identity)static <T, T2 extends T>
 booleancontainsAny(T[] array, T2[] other, boolean identity)static booleanequalsAny(java.lang.Object obj, java.lang.Object[] array)static booleanequalsAny(java.lang.Object obj, java.lang.Object[] array, int offset, int length)static floatgetRepeated(float[] array, int index)static intgetRepeated(int[] array, int index)static <T> TgetRepeated(T[] array, int index)static booleanregionEquals(byte[] array, int offset, byte[] other)static booleanregionEquals(byte[] array, int offset, int length, byte[] other)static booleanregionEquals(byte[] array, int offset, int length, byte[] other, int otherOffset)static booleanregionEquals(double[] array, int offset, double[] other, double epsilon)static booleanregionEquals(double[] array, int offset, int length, double[] other, double epsilon)static booleanregionEquals(double[] array, int offset, int length, double[] other, int otherOffset, double epsilon)static booleanregionEquals(float[] array, int offset, float[] other, float epsilon)static booleanregionEquals(float[] array, int offset, int length, float[] other, float epsilon)static booleanregionEquals(float[] array, int offset, int length, float[] other, int otherOffset, float epsilon)static booleanregionEquals(int[] array, int offset, int[] other)static booleanregionEquals(int[] array, int offset, int length, int[] other)static booleanregionEquals(int[] array, int offset, int length, int[] other, int otherOffset)static booleanregionEquals(long[] array, int offset, int length, long[] other)static booleanregionEquals(long[] array, int offset, int length, long[] other, int otherOffset)static booleanregionEquals(long[] array, int offset, long[] other)static booleanregionEquals(short[] array, int offset, int length, short[] other)static booleanregionEquals(short[] array, int offset, int length, short[] other, int otherOffset)static booleanregionEquals(short[] array, int offset, short[] other)static booleanregionEquals(java.lang.Object[] array, int offset, int length, java.lang.Object[] other, boolean identity)static booleanregionEquals(java.lang.Object[] array, int offset, int length, java.lang.Object[] other, int otherOffset, boolean identity)static booleanregionEquals(java.lang.Object[] array, int offset, java.lang.Object[] other, boolean identity)static intrepeat(int length, int index)static intrepeat(int offset, int length, int index)Repeats the given index within the given length (of an array).static voidrequireCapacity(float[] source, int offset, int length, float[] dest, int destOffset)throws an appropriate exception if the specified region of the source array cannot be copied to the destination array starting at the given offsetstatic voidrequireCapacity(int[] source, int offset, int length, int[] dest, int destOffset)throws an appropriate exception if the specified region of the source array cannot be copied to the destination array starting at the given offsetstatic voidrequireCapacity(java.lang.Object[] source, int offset, int length, java.lang.Object[] dest, int destOffset)throws an appropriate exception if the specified region of the source array cannot be copied to the destination array starting at the given offsetstatic float[]select(float[] items, int everyXth)static float[]select(float[] items, int[] indices)static float[]select(float[] items, int[] indices, float[] dest)static float[]select(float[] items, int[] indices, float[] dest, int destOffset)static float[]select(float[] items, int[] indices, int indicesOffset, int indicesLength, float[] dest, int destOffset)static float[]select(float[] items, int everyXth, float[] dest)static float[]select(float[] items, int start, int everyXth)static float[]select(float[] items, int start, int everyXth, float[] dest)static float[]select(float[] items, int offset, int length, int start, int everyXth)static float[]select(float[] items, int offset, int length, int start, int everyXth, float[] dest)static float[]select(float[] items, int offset, int length, int start, int everyXth, float[] dest, int destOffset)static int[]select(int[] items, int everyXth)static int[]select(int[] items, int[] indices)static int[]select(int[] items, int[] indices, int[] dest)static int[]select(int[] items, int[] indices, int[] dest, int destOffset)static int[]select(int[] items, int[] indices, int indicesOffset, int indicesLength, int[] dest, int destOffset)static int[]select(int[] items, int start, int everyXth)static int[]select(int[] items, int everyXth, int[] dest)static int[]select(int[] items, int start, int everyXth, int[] dest)static int[]select(int[] items, int offset, int length, int start, int everyXth)static int[]select(int[] items, int offset, int length, int start, int everyXth, int[] dest)static int[]select(int[] items, int offset, int length, int start, int everyXth, int[] dest, int destOffset)static <T> T[]select(T[] items, int everyXth)static <T> T[]select(T[] items, int[] indices)static <T> T[]select(T[] items, int[] indices, int indicesOffset, int indicesLength, T[] dest, int destOffset)static <T> T[]select(T[] items, int[] indices, T[] dest)static <T> T[]select(T[] items, int[] indices, T[] dest, int destOffset)static <T> T[]select(T[] items, int start, int everyXth)static <T> T[]select(T[] items, int offset, int length, int start, int everyXth)static <T> T[]select(T[] items, int offset, int length, int start, int everyXth, T[] dest)static <T> T[]select(T[] items, int offset, int length, int start, int everyXth, T[] dest, int destOffset)static <T> T[]select(T[] items, int start, int everyXth, T[] dest)static <T> T[]select(T[] items, int everyXth, T[] dest)static intselectCount(int offset, int length, int start, int everyXth)static voidshift(float[] array, int shift)static voidshift(float[] array, int offset, int length, int shift)static voidshift(int[] array, int shift)static voidshift(int[] array, int offset, int length, int shift)static voidshift(java.lang.Object[] array, int shift)static voidshift(java.lang.Object[] array, int offset, int length, int shift)static voidshuffle(float[] array)static voidshuffle(float[] array, int offset, int length)shuffles the given arraystatic voidshuffle(int[] array)static voidshuffle(int[] array, int offset, int length)shuffles the given arraystatic voidshuffle(java.lang.Object[] array)static voidshuffle(java.lang.Object[] array, int offset, int length)shuffles the given arraystatic java.lang.StringtoString(float[] array)static java.lang.StringtoString(float[] array, int offset, int length)static java.lang.StringtoString(float[] array, int offset, int length, java.lang.String separator)a more sophisticated version ofArrays.toString(Object[])static java.lang.StringtoString(float[] array, java.lang.String separator)static java.lang.StringtoString(int[] array)static java.lang.StringtoString(int[] array, int offset, int length)static java.lang.StringtoString(int[] array, int offset, int length, java.lang.String separator)a more sophisticated version ofArrays.toString(Object[])static java.lang.StringtoString(int[] array, java.lang.String separator)static java.lang.StringtoString(java.lang.Object[] array)static java.lang.StringtoString(java.lang.Object[] array, int offset, int length)static java.lang.StringtoString(java.lang.Object[] array, int offset, int length, java.lang.String separator)a more sophisticated version ofArrays.toString(Object[])static java.lang.StringtoString(java.lang.Object[] array, java.lang.String separator)static boolean[]unbox(java.lang.Boolean[] values)static float[]unbox(java.lang.Float[] values)static int[]unbox(java.lang.Integer[] values)Methods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
- 
Constructor Details- 
ArrayUtilspublic ArrayUtils()
 
- 
- 
Method Details- 
toStringpublic static java.lang.String toString(java.lang.Object[] array)- See Also:
- toString(Object[], int, int)
 
- 
toStringpublic static java.lang.String toString(java.lang.Object[] array, java.lang.String separator)- See Also:
- toString(Object[], int, int, String)
 
- 
toStringpublic static java.lang.String toString(java.lang.Object[] array, int offset, int length)- See Also:
- toString(Object[], int, int, String)
 
- 
toStringpublic static java.lang.String toString(java.lang.Object[] array, int offset, int length, java.lang.String separator)a more sophisticated version ofArrays.toString(Object[])
- 
toStringpublic static java.lang.String toString(int[] array)- See Also:
- toString(Object[], int, int)
 
- 
toStringpublic static java.lang.String toString(int[] array, java.lang.String separator)- See Also:
- toString(Object[], int, int, String)
 
- 
toStringpublic static java.lang.String toString(int[] array, int offset, int length)- See Also:
- toString(Object[], int, int, String)
 
- 
toStringpublic static java.lang.String toString(int[] array, int offset, int length, java.lang.String separator)a more sophisticated version ofArrays.toString(Object[])
- 
toStringpublic static java.lang.String toString(float[] array)- See Also:
- toString(Object[], int, int)
 
- 
toStringpublic static java.lang.String toString(float[] array, java.lang.String separator)- See Also:
- toString(Object[], int, int, String)
 
- 
toStringpublic static java.lang.String toString(float[] array, int offset, int length)- See Also:
- toString(Object[], int, int, String)
 
- 
toStringpublic static java.lang.String toString(float[] array, int offset, int length, java.lang.String separator)a more sophisticated version ofArrays.toString(Object[])
- 
getRepeatedpublic static <T> T getRepeated(T[] array, int index)- Parameters:
- array- the array from which to access a value at the wrapped index
- Returns:
- the value at the wrapped index
- See Also:
- repeat(int, int)
 
- 
getRepeatedpublic static int getRepeated(int[] array, int index)- See Also:
- getRepeated(Object[], int)
 
- 
getRepeatedpublic static float getRepeated(float[] array, int index)- See Also:
- getRepeated(Object[], int)
 
- 
repeatpublic static int repeat(int length, int index)- See Also:
- repeat(int, int, int)
 
- 
repeatpublic static int repeat(int offset, int length, int index)Repeats the given index within the given length (of an array). For example for a length of 10:
 index returns 0 0 5 5 10 0 15 5 20 0 55 5 - Parameters:
- length- the length of the array
- index- the index to repeat
- Returns:
- the repeated index
 
- 
containspublic static <T> boolean contains(T[] array, T value, boolean identity)- Parameters:
- array- the array that may contain the given value
- value- the value to search for in the given array
- identity- if- ==comparison should be used instead of- equals(Object)
- Returns:
- if the given value is contained in the given array
 
- 
containspublic static <T, T2 extends T> boolean contains(T[] array, T2[] other, boolean identity)- Type Parameters:
- T- the type of the containing array
- T2- the type of the contained array
- Parameters:
- array- the array to check if it contains the other array's values
- other- the array to check if it is contained in the other array
- Returns:
- if the second given array's values are completely contained in the first array
 
- 
containsAnypublic static <T, T2 extends T> boolean containsAny(T[] array, T2[] other, boolean identity)- Type Parameters:
- T- the type of the containing array
- T2- the type of the contained array
- Parameters:
- array- the array to check if it contains the other array's values
- other- the array to check if any of its values is contained in the other array
- Returns:
- if any value from the second array is contained in the first array
 
- 
regionEqualspublic static boolean regionEquals(java.lang.Object[] array, int offset, int length, java.lang.Object[] other, int otherOffset, boolean identity)- Parameters:
- offset- the region offset in the array
- length- the region length in the array
- otherOffset- the region offset in the other array
- identity- if- ==comparison should be used instead of- equals(Object)
- Returns:
- whether the specified region in both arrays matches
- Since:
- 0.13.5
 
- 
regionEqualspublic static boolean regionEquals(java.lang.Object[] array, int offset, int length, java.lang.Object[] other, boolean identity)
- 
regionEqualspublic static boolean regionEquals(java.lang.Object[] array, int offset, java.lang.Object[] other, boolean identity)
- 
regionEqualspublic static boolean regionEquals(long[] array, int offset, int length, long[] other, int otherOffset)
- 
regionEqualspublic static boolean regionEquals(long[] array, int offset, int length, long[] other)
- 
regionEqualspublic static boolean regionEquals(long[] array, int offset, long[] other)- See Also:
- regionEquals(long[], int, int, long[])
 
- 
regionEqualspublic static boolean regionEquals(int[] array, int offset, int length, int[] other, int otherOffset)
- 
regionEqualspublic static boolean regionEquals(int[] array, int offset, int length, int[] other)
- 
regionEqualspublic static boolean regionEquals(int[] array, int offset, int[] other)- See Also:
- regionEquals(int[], int, int, int[])
 
- 
regionEqualspublic static boolean regionEquals(double[] array, int offset, int length, double[] other, int otherOffset, double epsilon)
- 
regionEqualspublic static boolean regionEquals(double[] array, int offset, int length, double[] other, double epsilon)
- 
regionEqualspublic static boolean regionEquals(double[] array, int offset, double[] other, double epsilon)
- 
regionEqualspublic static boolean regionEquals(float[] array, int offset, int length, float[] other, int otherOffset, float epsilon)
- 
regionEqualspublic static boolean regionEquals(float[] array, int offset, int length, float[] other, float epsilon)
- 
regionEqualspublic static boolean regionEquals(float[] array, int offset, float[] other, float epsilon)
- 
regionEqualspublic static boolean regionEquals(short[] array, int offset, int length, short[] other, int otherOffset)
- 
regionEqualspublic static boolean regionEquals(short[] array, int offset, int length, short[] other)
- 
regionEqualspublic static boolean regionEquals(short[] array, int offset, short[] other)- See Also:
- regionEquals(short[], int, int, short[])
 
- 
regionEqualspublic static boolean regionEquals(byte[] array, int offset, int length, byte[] other, int otherOffset)
- 
regionEqualspublic static boolean regionEquals(byte[] array, int offset, int length, byte[] other)
- 
regionEqualspublic static boolean regionEquals(byte[] array, int offset, byte[] other)- See Also:
- regionEquals(byte[], int, int, byte[])
 
- 
equalsAnypublic static boolean equalsAny(java.lang.Object obj, java.lang.Object[] array, int offset, int length)- Parameters:
- obj- the object to compare
- array- the array which items to compare
- Returns:
- if the given object equals any of the items in the given array
 
- 
equalsAnypublic static boolean equalsAny(java.lang.Object obj, java.lang.Object[] array)- See Also:
- equalsAny(Object, Object[], int, int)
 
- 
shiftpublic static void shift(java.lang.Object[] array, int shift)- See Also:
- shift(Object[], int, int, int)
 
- 
shiftpublic static void shift(java.lang.Object[] array, int offset, int length, int shift)- Parameters:
- array- the array to shift
- shift- The amount by which to shift. 1 means that every item will be moved 1 index to the right.
 
- 
shiftpublic static void shift(int[] array, int shift)- See Also:
- shift(int[], int, int, int)
 
- 
shiftpublic static void shift(int[] array, int offset, int length, int shift)- Parameters:
- array- the array to shift
- shift- The amount by which to shift. 1 means that every item will be moved 1 index to the right.
 
- 
shiftpublic static void shift(float[] array, int shift)- See Also:
- shift(float[], int, int, int)
 
- 
shiftpublic static void shift(float[] array, int offset, int length, int shift)- Parameters:
- array- the array to shift
- shift- The amount by which to shift. 1 means that every item will be moved 1 index to the right.
 
- 
shufflepublic static void shuffle(java.lang.Object[] array)- See Also:
- shuffle(Object[], int, int)
 
- 
shufflepublic static void shuffle(java.lang.Object[] array, int offset, int length)shuffles the given array- Parameters:
- array- the array to shuffle
 
- 
shufflepublic static void shuffle(int[] array)- See Also:
- shuffle(int[], int, int)
 
- 
shufflepublic static void shuffle(int[] array, int offset, int length)shuffles the given array- Parameters:
- array- the array to shuffle
 
- 
shufflepublic static void shuffle(float[] array)- See Also:
- shuffle(float[], int, int)
 
- 
shufflepublic static void shuffle(float[] array, int offset, int length)shuffles the given array- Parameters:
- array- the array to shuffle
 
- 
unboxpublic static float[] unbox(java.lang.Float[] values)- Returns:
- an array of the unboxed values from the given values
- See Also:
- box(float[])
 
- 
boxpublic static java.lang.Float[] box(float[] values)- Returns:
- an array of the boxed values from the given values
- See Also:
- unbox(Float[])
 
- 
unboxpublic static int[] unbox(java.lang.Integer[] values)- Returns:
- an array of the unboxed values from the given values
- See Also:
- box(int[])
 
- 
boxpublic static java.lang.Integer[] box(int[] values)- Returns:
- an array of the boxed values from the given values
- See Also:
- unbox(Integer[])
 
- 
unboxpublic static boolean[] unbox(java.lang.Boolean[] values)- Returns:
- an array of the unboxed values from the given values
- See Also:
- box(boolean[])
 
- 
boxpublic static java.lang.Boolean[] box(boolean[] values)- Returns:
- an array of the boxed values from the given values
- See Also:
- unbox(Boolean[])
 
- 
checkRegionpublic static void checkRegion(java.lang.Object[] array, int offset, int length)- Throws:
- java.lang.ArrayIndexOutOfBoundsException- if an invalid region is specified
- java.lang.IllegalArgumentException- if the array is null
 
- 
requireCapacitypublic static void requireCapacity(java.lang.Object[] source, int offset, int length, java.lang.Object[] dest, int destOffset)throws an appropriate exception if the specified region of the source array cannot be copied to the destination array starting at the given offset- Throws:
- java.lang.ArrayIndexOutOfBoundsException
- java.lang.IllegalArgumentException
- See Also:
- checkRegion(Object[], int, int)
 
- 
selectCountpublic static int selectCount(int offset, int length, int start, int everyXth)- Parameters:
- start- the index at which to start (may be negative)
- offset- the index at which the array interval to use
- length- the length of the array interval to use
- everyXth- select every xth item
- Returns:
- the capacity needed in the output array
- See Also:
- select(Object[], int, int, int, int, Object[], int)
 
- 
selectpublic static <T> T[] select(T[] items, int offset, int length, int start, int everyXth, T[] dest, int destOffset)- Parameters:
- items- the items to select from
- start- the array index at which to start (may be negative)
- everyXth- select every xth of items
- dest- The array to put the values in. Must have at least the capacity returned by- selectCount.
- Returns:
- the dest array containing everyXth item of the given items array
- Throws:
- java.lang.IllegalArgumentException- if the given dest array is not null and smaller than the required length
 
- 
selectpublic static <T> T[] select(T[] items, int offset, int length, int start, int everyXth, T[] dest)
- 
selectpublic static <T> T[] select(T[] items, int start, int everyXth, T[] dest)
- 
selectpublic static <T> T[] select(T[] items, int everyXth, T[] dest)- See Also:
- select(Object[], int, int, Object[])
 
- 
selectpublic static <T> T[] select(T[] items, int offset, int length, int start, int everyXth)
- 
selectpublic static <T> T[] select(T[] items, int start, int everyXth)- See Also:
- select(Object[], int, int, int, int)
 
- 
selectpublic static <T> T[] select(T[] items, int everyXth)- See Also:
- select(Object[], int, int)
 
- 
selectpublic static <T> T[] select(T[] items, int[] indices, int indicesOffset, int indicesLength, T[] dest, int destOffset)- Parameters:
- items- the items to select from
- indices- the indices to select
- dest- the array to fill
- Returns:
- the given dest array
 
- 
selectpublic static <T> T[] select(T[] items, int[] indices, T[] dest, int destOffset)
- 
selectpublic static <T> T[] select(T[] items, int[] indices, T[] dest)- See Also:
- select(Object[], int[], Object[], int)
 
- 
selectpublic static <T> T[] select(T[] items, int[] indices)- See Also:
- select(Object[], int[], Object[])
 
- 
checkRegionpublic static void checkRegion(float[] array, int offset, int length)- Throws:
- java.lang.ArrayIndexOutOfBoundsException- if an invalid region is specified
- java.lang.NullPointerException- if the array is null
 
- 
requireCapacitypublic static void requireCapacity(float[] source, int offset, int length, float[] dest, int destOffset)throws an appropriate exception if the specified region of the source array cannot be copied to the destination array starting at the given offset- Throws:
- java.lang.ArrayIndexOutOfBoundsException
- java.lang.IllegalArgumentException
- See Also:
- checkRegion(float[], int, int)
 
- 
selectpublic static float[] select(float[] items, int offset, int length, int start, int everyXth, float[] dest, int destOffset)- Parameters:
- items- the items to select from
- start- the array index at which to start (may be negative)
- everyXth- select every xth of items
- dest- The array to put the values in. Must have at least the capacity returned by- selectCount.
- Returns:
- the dest array containing everyXth item of the given items array
- Throws:
- java.lang.IllegalArgumentException- if the given dest array is not null and smaller than the required length
 
- 
selectpublic static float[] select(float[] items, int offset, int length, int start, int everyXth, float[] dest)
- 
selectpublic static float[] select(float[] items, int start, int everyXth, float[] dest)
- 
selectpublic static float[] select(float[] items, int everyXth, float[] dest)- See Also:
- select(Object[], int, int, Object[])
 
- 
selectpublic static float[] select(float[] items, int offset, int length, int start, int everyXth)
- 
selectpublic static float[] select(float[] items, int start, int everyXth)- See Also:
- select(Object[], int, int, int, int)
 
- 
selectpublic static float[] select(float[] items, int everyXth)- See Also:
- select(Object[], int, int)
 
- 
selectpublic static float[] select(float[] items, int[] indices, int indicesOffset, int indicesLength, float[] dest, int destOffset)- Parameters:
- items- the items to select from
- indices- the indices to select
- dest- the array to fill
- Returns:
- the given dest array
 
- 
selectpublic static float[] select(float[] items, int[] indices, float[] dest, int destOffset)
- 
selectpublic static float[] select(float[] items, int[] indices, float[] dest)- See Also:
- select(Object[], int[], Object[], int)
 
- 
selectpublic static float[] select(float[] items, int[] indices)- See Also:
- select(Object[], int[], Object[])
 
- 
checkRegionpublic static void checkRegion(int[] array, int offset, int length)- Throws:
- java.lang.ArrayIndexOutOfBoundsException- if an invalid region is specified
- java.lang.IllegalArgumentException- if the array is null
 
- 
requireCapacitypublic static void requireCapacity(int[] source, int offset, int length, int[] dest, int destOffset)throws an appropriate exception if the specified region of the source array cannot be copied to the destination array starting at the given offset- Throws:
- java.lang.ArrayIndexOutOfBoundsException
- java.lang.IllegalArgumentException
- See Also:
- checkRegion(int[], int, int)
 
- 
selectpublic static int[] select(int[] items, int offset, int length, int start, int everyXth, int[] dest, int destOffset)- Parameters:
- items- the items to select from
- start- the array index at which to start (may be negative)
- everyXth- select every xth of items
- dest- The array to put the values in. Must have at least the capacity returned by- selectCount.
- Returns:
- the dest array containing everyXth item of the given items array
- Throws:
- java.lang.IllegalArgumentException- if the given dest array is not null and smaller than the required length
 
- 
selectpublic static int[] select(int[] items, int offset, int length, int start, int everyXth, int[] dest)
- 
selectpublic static int[] select(int[] items, int start, int everyXth, int[] dest)
- 
selectpublic static int[] select(int[] items, int everyXth, int[] dest)- See Also:
- select(Object[], int, int, Object[])
 
- 
selectpublic static int[] select(int[] items, int offset, int length, int start, int everyXth)
- 
selectpublic static int[] select(int[] items, int start, int everyXth)- See Also:
- select(Object[], int, int, int, int)
 
- 
selectpublic static int[] select(int[] items, int everyXth)- See Also:
- select(Object[], int, int)
 
- 
selectpublic static int[] select(int[] items, int[] indices, int indicesOffset, int indicesLength, int[] dest, int destOffset)- Parameters:
- items- the items to select from
- indices- the indices to select
- dest- the array to fill
- Returns:
- the given dest array
 
- 
selectpublic static int[] select(int[] items, int[] indices, int[] dest, int destOffset)
- 
selectpublic static int[] select(int[] items, int[] indices, int[] dest)- See Also:
- select(Object[], int[], Object[], int)
 
- 
selectpublic static int[] select(int[] items, int[] indices)- See Also:
- select(Object[], int[], Object[])
 
 
-