Package net.thevpc.common.util
Class Utils
java.lang.Object
net.thevpc.common.util.Utils
- Author:
- taha.bensalah@gmail.com
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic intcompare(byte x, byte y) static intcompare(double d1, double d2) static intcompare(float f1, float f2) static intcompare(int x, int y) static intcompare(long x, long y) static intstatic intcompare(Object a, Object b, Comparator c) static boolean[]copyOf(boolean[] original, int newLength) Copies the specified array, truncating or padding with false (if necessary) so the copy has the specified length.static char[]copyOf(char[] original, int newLength) Copies the specified array, truncating or padding with null characters (if necessary) so the copy has the specified length.static double[]copyOf(double[] original, int newLength) Copies the specified array, truncating or padding with zeros (if necessary) so the copy has the specified length.static float[]copyOf(float[] original, int newLength) Copies the specified array, truncating or padding with zeros (if necessary) so the copy has the specified length.static int[]copyOf(int[] original, int newLength) Copies the specified array, truncating or padding with zeros (if necessary) so the copy has the specified length.static long[]copyOf(long[] original, int newLength) Copies the specified array, truncating or padding with zeros (if necessary) so the copy has the specified length.static short[]copyOf(short[] original, int newLength) static <T> T[]copyOf(T[] original, int newLength) static <T,U> T[] static ObjectcopyOfArray(Object array) static intfibonacci(int number) static intstatic <T,V> V static longstatic booleanstatic ObjectjoinArrays(Object... arrays) static ObjectjoinArraysAsType(Class componentType, Object... arrays) static longstatic <T> Tstatic <T> voidstatic ObjectnonEmptyValue(Object... objects) static ObjectnonNullValue(Object... objects) static intrand(int min, int max) static <T> Tstatic <T> Tstatic <T> Trand(T[] values) static ObjectremoveArray(Object array, int offset, int removeCount) static ObjectremoveArrayTail(Object array, int offset, int removeCount) static <T,V> List<T> sort(List<T> list, Function<T, V> converter, Comparator<V> c) static <T,V> T[] sort(T[] arr, Function<T, V> converter, Comparator<V> c)
-
Constructor Details
-
Utils
public Utils()
-
-
Method Details
-
compare
-
compare
-
joinArrays
-
joinArraysAsType
-
copyOfArray
-
removeArrayTail
-
removeArray
-
ifType
-
ncastDo
-
ncast
-
isEmpty
-
nonNullValue
-
nonEmptyValue
-
fibonacci
public static int fibonacci(int number) -
rand
public static int rand(int min, int max) -
rand
-
rand
public static <T> T rand(T[] values) -
rand
-
inUseMemory
public static long inUseMemory() -
maxFreeMemory
public static long maxFreeMemory() -
compare
public static int compare(byte x, byte y) -
compare
public static int compare(int x, int y) -
compare
public static int compare(long x, long y) -
compare
public static int compare(double d1, double d2) -
compare
public static int compare(float f1, float f2) -
hashCode
-
copyOf
public static <T> T[] copyOf(T[] original, int newLength) -
copyOf
-
copyOf
public static short[] copyOf(short[] original, int newLength) -
copyOf
public static int[] copyOf(int[] original, int newLength) Copies the specified array, truncating or padding with zeros (if necessary) so the copy has the specified length. For all indices that are valid in both the original array and the copy, the two arrays will contain identical values. For any indices that are valid in the copy but not the original, the copy will contain 0. Such indices will exist if and only if the specified length is greater than that of the original array.- Parameters:
original- the array to be copiednewLength- the length of the copy to be returned- Returns:
- a copy of the original array, truncated or padded with zeros to obtain the specified length
- Throws:
NegativeArraySizeException- if newLength is negativeNullPointerException- if original is null- Since:
- 1.6
-
copyOf
public static long[] copyOf(long[] original, int newLength) Copies the specified array, truncating or padding with zeros (if necessary) so the copy has the specified length. For all indices that are valid in both the original array and the copy, the two arrays will contain identical values. For any indices that are valid in the copy but not the original, the copy will contain 0L. Such indices will exist if and only if the specified length is greater than that of the original array.- Parameters:
original- the array to be copiednewLength- the length of the copy to be returned- Returns:
- a copy of the original array, truncated or padded with zeros to obtain the specified length
- Throws:
NegativeArraySizeException- if newLength is negativeNullPointerException- if original is null- Since:
- 1.6
-
copyOf
public static char[] copyOf(char[] original, int newLength) Copies the specified array, truncating or padding with null characters (if necessary) so the copy has the specified length. For all indices that are valid in both the original array and the copy, the two arrays will contain identical values. For any indices that are valid in the copy but not the original, the copy will contain '\\u000'. Such indices will exist if and only if the specified length is greater than that of the original array.- Parameters:
original- the array to be copiednewLength- the length of the copy to be returned- Returns:
- a copy of the original array, truncated or padded with null characters to obtain the specified length
- Throws:
NegativeArraySizeException- if newLength is negativeNullPointerException- if original is null- Since:
- 1.6
-
copyOf
public static float[] copyOf(float[] original, int newLength) Copies the specified array, truncating or padding with zeros (if necessary) so the copy has the specified length. For all indices that are valid in both the original array and the copy, the two arrays will contain identical values. For any indices that are valid in the copy but not the original, the copy will contain 0f. Such indices will exist if and only if the specified length is greater than that of the original array.- Parameters:
original- the array to be copiednewLength- the length of the copy to be returned- Returns:
- a copy of the original array, truncated or padded with zeros to obtain the specified length
- Throws:
NegativeArraySizeException- if newLength is negativeNullPointerException- if original is null- Since:
- 1.6
-
copyOf
public static double[] copyOf(double[] original, int newLength) Copies the specified array, truncating or padding with zeros (if necessary) so the copy has the specified length. For all indices that are valid in both the original array and the copy, the two arrays will contain identical values. For any indices that are valid in the copy but not the original, the copy will contain 0d. Such indices will exist if and only if the specified length is greater than that of the original array.- Parameters:
original- the array to be copiednewLength- the length of the copy to be returned- Returns:
- a copy of the original array, truncated or padded with zeros to obtain the specified length
- Throws:
NegativeArraySizeException- if newLength is negativeNullPointerException- if original is null- Since:
- 1.6
-
copyOf
public static boolean[] copyOf(boolean[] original, int newLength) Copies the specified array, truncating or padding with false (if necessary) so the copy has the specified length. For all indices that are valid in both the original array and the copy, the two arrays will contain identical values. For any indices that are valid in the copy but not the original, the copy will contain false. Such indices will exist if and only if the specified length is greater than that of the original array.- Parameters:
original- the array to be copiednewLength- the length of the copy to be returned- Returns:
- a copy of the original array, truncated or padded with false elements to obtain the specified length
- Throws:
NegativeArraySizeException- if newLength is negativeNullPointerException- if original is null- Since:
- 1.6
-
sort
-
sort
-