Package net.dermetfan.utils
Class ArrayUtils
java.lang.Object
net.dermetfan.utils.ArrayUtils
- Direct Known Subclasses:
ArrayUtils
array utility methods
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic Boolean[]box(boolean[] values) static Float[]box(float[] values) static Integer[]box(int[] values) static voidcheckRegion(float[] array, int offset, int length) static voidcheckRegion(int[] array, int offset, int length) static voidcheckRegion(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 booleanstatic booleanstatic 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(Object[] array, int offset, int length, Object[] other, boolean identity) static booleanregionEquals(Object[] array, int offset, int length, Object[] other, int otherOffset, boolean identity) static booleanregionEquals(Object[] array, int offset, 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(Object[] source, int offset, int length, 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 voidstatic voidstatic 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 voidstatic voidshuffles the given arraystatic StringtoString(float[] array) static StringtoString(float[] array, int offset, int length) static Stringa more sophisticated version ofArrays.toString(Object[])static Stringstatic StringtoString(int[] array) static StringtoString(int[] array, int offset, int length) static Stringa more sophisticated version ofArrays.toString(Object[])static Stringstatic Stringstatic Stringstatic Stringa more sophisticated version ofArrays.toString(Object[])static Stringstatic boolean[]static float[]static int[]
-
Constructor Details
-
ArrayUtils
public ArrayUtils()
-
-
Method Details
-
toString
- See Also:
-
toString
- See Also:
-
toString
- See Also:
-
toString
a more sophisticated version ofArrays.toString(Object[]) -
toString
- See Also:
-
toString
- See Also:
-
toString
- See Also:
-
toString
a more sophisticated version ofArrays.toString(Object[]) -
toString
- See Also:
-
toString
- See Also:
-
toString
- See Also:
-
toString
a more sophisticated version ofArrays.toString(Object[]) -
getRepeated
public 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:
-
getRepeated
public static int getRepeated(int[] array, int index) - See Also:
-
getRepeated
public static float getRepeated(float[] array, int index) - See Also:
-
repeat
public static int repeat(int length, int index) - See Also:
-
repeat
public 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 and return value index returns 0 0 5 5 10 0 15 5 20 0 55 5 - Parameters:
length- the length of the arrayindex- the index to repeat- Returns:
- the repeated index
-
contains
public static <T> boolean contains(T[] array, T value, boolean identity) - Parameters:
array- the array that may contain the given valuevalue- the value to search for in the given arrayidentity- if==comparison should be used instead ofequals(Object)- Returns:
- if the given value is contained in the given array
-
contains
public static <T,T2 extends T> boolean contains(T[] array, T2[] other, boolean identity) - Type Parameters:
T- the type of the containing arrayT2- the type of the contained array- Parameters:
array- the array to check if it contains the other array's valuesother- 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
-
containsAny
public static <T,T2 extends T> boolean containsAny(T[] array, T2[] other, boolean identity) - Type Parameters:
T- the type of the containing arrayT2- the type of the contained array- Parameters:
array- the array to check if it contains the other array's valuesother- 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
-
regionEquals
public static boolean regionEquals(Object[] array, int offset, int length, Object[] other, int otherOffset, boolean identity) - Parameters:
offset- the region offset in the arraylength- the region length in the arrayotherOffset- the region offset in the other arrayidentity- if==comparison should be used instead ofequals(Object)- Returns:
- whether the specified region in both arrays matches
- Since:
- 0.13.5
-
regionEquals
public static boolean regionEquals(Object[] array, int offset, int length, Object[] other, boolean identity) - See Also:
-
regionEquals
- See Also:
-
regionEquals
public static boolean regionEquals(long[] array, int offset, int length, long[] other, int otherOffset) - See Also:
-
regionEquals
public static boolean regionEquals(long[] array, int offset, int length, long[] other) - See Also:
-
regionEquals
public static boolean regionEquals(long[] array, int offset, long[] other) - See Also:
-
regionEquals
public static boolean regionEquals(int[] array, int offset, int length, int[] other, int otherOffset) - See Also:
-
regionEquals
public static boolean regionEquals(int[] array, int offset, int length, int[] other) - See Also:
-
regionEquals
public static boolean regionEquals(int[] array, int offset, int[] other) - See Also:
-
regionEquals
public static boolean regionEquals(double[] array, int offset, int length, double[] other, int otherOffset, double epsilon) - See Also:
-
regionEquals
public static boolean regionEquals(double[] array, int offset, int length, double[] other, double epsilon) - See Also:
-
regionEquals
public static boolean regionEquals(double[] array, int offset, double[] other, double epsilon) - See Also:
-
regionEquals
public static boolean regionEquals(float[] array, int offset, int length, float[] other, int otherOffset, float epsilon) - See Also:
-
regionEquals
public static boolean regionEquals(float[] array, int offset, int length, float[] other, float epsilon) - See Also:
-
regionEquals
public static boolean regionEquals(float[] array, int offset, float[] other, float epsilon) - See Also:
-
regionEquals
public static boolean regionEquals(short[] array, int offset, int length, short[] other, int otherOffset) - See Also:
-
regionEquals
public static boolean regionEquals(short[] array, int offset, int length, short[] other) - See Also:
-
regionEquals
public static boolean regionEquals(short[] array, int offset, short[] other) - See Also:
-
regionEquals
public static boolean regionEquals(byte[] array, int offset, int length, byte[] other, int otherOffset) - See Also:
-
regionEquals
public static boolean regionEquals(byte[] array, int offset, int length, byte[] other) - See Also:
-
regionEquals
public static boolean regionEquals(byte[] array, int offset, byte[] other) - See Also:
-
equalsAny
- Parameters:
obj- the object to comparearray- the array which items to compare- Returns:
- if the given object equals any of the items in the given array
-
equalsAny
- See Also:
-
shift
- See Also:
-
shift
- Parameters:
array- the array to shiftshift- The amount by which to shift. 1 means that every item will be moved 1 index to the right.
-
shift
public static void shift(int[] array, int shift) - See Also:
-
shift
public static void shift(int[] array, int offset, int length, int shift) - Parameters:
array- the array to shiftshift- The amount by which to shift. 1 means that every item will be moved 1 index to the right.
-
shift
public static void shift(float[] array, int shift) - See Also:
-
shift
public static void shift(float[] array, int offset, int length, int shift) - Parameters:
array- the array to shiftshift- The amount by which to shift. 1 means that every item will be moved 1 index to the right.
-
shuffle
- See Also:
-
shuffle
shuffles the given array- Parameters:
array- the array to shuffle
-
shuffle
public static void shuffle(int[] array) - See Also:
-
shuffle
public static void shuffle(int[] array, int offset, int length) shuffles the given array- Parameters:
array- the array to shuffle
-
shuffle
public static void shuffle(float[] array) - See Also:
-
shuffle
public static void shuffle(float[] array, int offset, int length) shuffles the given array- Parameters:
array- the array to shuffle
-
unbox
- Returns:
- an array of the unboxed values from the given values
- See Also:
-
box
- Returns:
- an array of the boxed values from the given values
- See Also:
-
unbox
- Returns:
- an array of the unboxed values from the given values
- See Also:
-
box
- Returns:
- an array of the boxed values from the given values
- See Also:
-
unbox
- Returns:
- an array of the unboxed values from the given values
- See Also:
-
box
- Returns:
- an array of the boxed values from the given values
- See Also:
-
checkRegion
- Throws:
ArrayIndexOutOfBoundsException- if an invalid region is specifiedIllegalArgumentException- if the array is null
-
requireCapacity
public static void requireCapacity(Object[] source, int offset, int length, 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:
ArrayIndexOutOfBoundsExceptionIllegalArgumentException- See Also:
-
selectCount
public static int selectCount(int offset, int length, int start, int everyXth) - Parameters:
offset- the index at which the array interval to uselength- the length of the array interval to usestart- the index at which to start (may be negative)everyXth- select every xth item- Returns:
- the capacity needed in the output array
- See Also:
-
select
public static <T> T[] select(T[] items, int offset, int length, int start, int everyXth, T[] dest, int destOffset) - Parameters:
items- the items to select fromstart- the array index at which to start (may be negative)everyXth- select every xth of itemsdest- The array to put the values in. Must have at least the capacity returned byselectCount.- Returns:
- the dest array containing everyXth item of the given items array
- Throws:
IllegalArgumentException- if the given dest array is not null and smaller than the required length
-
select
public static <T> T[] select(T[] items, int offset, int length, int start, int everyXth, T[] dest) - See Also:
-
select
public static <T> T[] select(T[] items, int start, int everyXth, T[] dest) - See Also:
-
select
public static <T> T[] select(T[] items, int everyXth, T[] dest) - See Also:
-
select
public static <T> T[] select(T[] items, int offset, int length, int start, int everyXth) - See Also:
-
select
public static <T> T[] select(T[] items, int start, int everyXth) - See Also:
-
select
public static <T> T[] select(T[] items, int everyXth) - See Also:
-
select
public static <T> T[] select(T[] items, int[] indices, int indicesOffset, int indicesLength, T[] dest, int destOffset) - Parameters:
items- the items to select fromindices- the indices to selectdest- the array to fill- Returns:
- the given dest array
-
select
public static <T> T[] select(T[] items, int[] indices, T[] dest, int destOffset) - See Also:
-
select
public static <T> T[] select(T[] items, int[] indices, T[] dest) - See Also:
-
select
public static <T> T[] select(T[] items, int[] indices) - See Also:
-
checkRegion
public static void checkRegion(float[] array, int offset, int length) - Throws:
ArrayIndexOutOfBoundsException- if an invalid region is specifiedNullPointerException- if the array is null
-
requireCapacity
public 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:
ArrayIndexOutOfBoundsExceptionIllegalArgumentException- See Also:
-
select
public static float[] select(float[] items, int offset, int length, int start, int everyXth, float[] dest, int destOffset) - Parameters:
items- the items to select fromstart- the array index at which to start (may be negative)everyXth- select every xth of itemsdest- The array to put the values in. Must have at least the capacity returned byselectCount.- Returns:
- the dest array containing everyXth item of the given items array
- Throws:
IllegalArgumentException- if the given dest array is not null and smaller than the required length
-
select
public static float[] select(float[] items, int offset, int length, int start, int everyXth, float[] dest) - See Also:
-
select
public static float[] select(float[] items, int start, int everyXth, float[] dest) - See Also:
-
select
public static float[] select(float[] items, int everyXth, float[] dest) - See Also:
-
select
public static float[] select(float[] items, int offset, int length, int start, int everyXth) - See Also:
-
select
public static float[] select(float[] items, int start, int everyXth) - See Also:
-
select
public static float[] select(float[] items, int everyXth) - See Also:
-
select
public static float[] select(float[] items, int[] indices, int indicesOffset, int indicesLength, float[] dest, int destOffset) - Parameters:
items- the items to select fromindices- the indices to selectdest- the array to fill- Returns:
- the given dest array
-
select
public static float[] select(float[] items, int[] indices, float[] dest, int destOffset) - See Also:
-
select
public static float[] select(float[] items, int[] indices, float[] dest) - See Also:
-
select
public static float[] select(float[] items, int[] indices) - See Also:
-
checkRegion
public static void checkRegion(int[] array, int offset, int length) - Throws:
ArrayIndexOutOfBoundsException- if an invalid region is specifiedIllegalArgumentException- if the array is null
-
requireCapacity
public 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:
ArrayIndexOutOfBoundsExceptionIllegalArgumentException- See Also:
-
select
public static int[] select(int[] items, int offset, int length, int start, int everyXth, int[] dest, int destOffset) - Parameters:
items- the items to select fromstart- the array index at which to start (may be negative)everyXth- select every xth of itemsdest- The array to put the values in. Must have at least the capacity returned byselectCount.- Returns:
- the dest array containing everyXth item of the given items array
- Throws:
IllegalArgumentException- if the given dest array is not null and smaller than the required length
-
select
public static int[] select(int[] items, int offset, int length, int start, int everyXth, int[] dest) - See Also:
-
select
public static int[] select(int[] items, int start, int everyXth, int[] dest) - See Also:
-
select
public static int[] select(int[] items, int everyXth, int[] dest) - See Also:
-
select
public static int[] select(int[] items, int offset, int length, int start, int everyXth) - See Also:
-
select
public static int[] select(int[] items, int start, int everyXth) - See Also:
-
select
public static int[] select(int[] items, int everyXth) - See Also:
-
select
public static int[] select(int[] items, int[] indices, int indicesOffset, int indicesLength, int[] dest, int destOffset) - Parameters:
items- the items to select fromindices- the indices to selectdest- the array to fill- Returns:
- the given dest array
-
select
public static int[] select(int[] items, int[] indices, int[] dest, int destOffset) - See Also:
-
select
public static int[] select(int[] items, int[] indices, int[] dest) - See Also:
-
select
public static int[] select(int[] items, int[] indices) - See Also:
-