public final class Arrays2
extends java.lang.Object
| Modifier and Type | Method and Description |
|---|---|
static float[] |
readFloatArray(java.io.DataInputStream dataInputStream)
Reads
float values from dataInputStream and adds them to a float[]. |
static float[] |
readFloatArray(java.io.DataInputStream dataInputStream,
float[] array)
Reads
float values from dataInputStream and adds them to array. |
static int[] |
readIntArray(java.io.DataInputStream dataInputStream)
Reads
int values from dataInputStream and adds them to an int[]. |
static <T> float[] |
toFloatArray(java.util.List<T> list,
java.util.function.Function<T,float[]> function)
Returns a larger
float[] by merging smaller float[] together. |
static <T> float[] |
toFloatArray(java.util.List<T> list,
java.util.function.Function<T,float[]> function,
int minimumLength)
Returns a larger
float[] by merging smaller float[] together. |
static <T> int[] |
toIntArray(java.util.List<T> list,
java.util.function.Function<T,int[]> function)
Returns a larger
int[] by merging smaller int[] together. |
static <T> int[] |
toIntArray(java.util.List<T> list,
java.util.function.Function<T,int[]> function,
int minimumLength)
Returns a larger
int[] by merging smaller int[] together. |
static void |
writeFloatArray(java.io.DataOutputStream dataOutputStream,
float[] array)
Writes the
float values of array into dataOutputStream. |
static void |
writeIntArray(java.io.DataOutputStream dataOutputStream,
int[] array)
Writes the
int values of array into dataOutputStream. |
public static float[] readFloatArray(java.io.DataInputStream dataInputStream)
throws java.io.IOException
float values from dataInputStream and adds them to a float[].
Returns the float[].
If dataInputStream is null, a NullPointerException will be thrown.
If an I/O error occurs, an IOException will be thrown.
dataInputStream - the DataInputStream to read fromfloat[]java.io.IOException - thrown if, and only if, an I/O error occursjava.lang.NullPointerException - thrown if, and only if, dataInputStream is nullpublic static float[] readFloatArray(java.io.DataInputStream dataInputStream,
float[] array)
throws java.io.IOException
float values from dataInputStream and adds them to array.
Returns array.
If dataInputStream is null, a NullPointerException will be thrown.
If an I/O error occurs, an IOException will be thrown.
If array.length is less than the length read from dataInputStream, an ArrayIndexOutOfBoundsException will be thrown.
dataInputStream - the DataInputStream to read fromarray - the float array to write to and returnarrayjava.lang.ArrayIndexOutOfBoundsException - thrown if, and only if, array.length is less than the length read from dataInputStreamjava.io.IOException - thrown if, and only if, an I/O error occursjava.lang.NullPointerException - thrown if, and only if, dataInputStream is nullpublic static <T> float[] toFloatArray(java.util.List<T> list,
java.util.function.Function<T,float[]> function)
float[] by merging smaller float[] together.
Calling this method is equivalent to toFloatArray(list, function, 0).
If either list or function are null, or function returns null, a NullPointerException will be thrown.
If an element in list is null, a NullPointerException might be thrown. But no guarantees can be made. This is up to function.
T - the generic type to uselist - a Listfunction - a Function mapping Lists elements to float[]float[] by merging smaller float[] togetherjava.lang.NullPointerException - thrown if, and only if, either list or function are null, or function returns nullpublic static <T> float[] toFloatArray(java.util.List<T> list,
java.util.function.Function<T,float[]> function,
int minimumLength)
float[] by merging smaller float[] together.
If either list or function are null, or function returns null, a NullPointerException will be thrown.
If an element in list is null, a NullPointerException might be thrown. But no guarantees can be made. This is up to function.
If the length of the larger float[] is less than minimumLength, a new empty float[] with minimumLength as length will be returned.
T - the generic type to uselist - a Listfunction - a Function mapping Lists elements to float[]minimumLength - the minimum length of the float[] to returnfloat[] by merging smaller float[] togetherjava.lang.NullPointerException - thrown if, and only if, either list or function are null, or function returns nullpublic static int[] readIntArray(java.io.DataInputStream dataInputStream)
throws java.io.IOException
int values from dataInputStream and adds them to an int[].
Returns the int[].
If dataInputStream is null, a NullPointerException will be thrown.
If an I/O error occurs, an IOException will be thrown.
dataInputStream - the DataInputStream to read fromint[]java.io.IOException - thrown if, and only if, an I/O error occursjava.lang.NullPointerException - thrown if, and only if, dataInputStream is nullpublic static <T> int[] toIntArray(java.util.List<T> list,
java.util.function.Function<T,int[]> function)
int[] by merging smaller int[] together.
Calling this method is equivalent to toIntArray(list, function, 0).
If either list or function are null, or function returns null, a NullPointerException will be thrown.
If an element in list is null, a NullPointerException might be thrown. But no guarantees can be made. This is up to function.
T - the generic type to uselist - a Listfunction - a Function mapping Lists elements to int[]int[] by merging smaller int[] togetherjava.lang.NullPointerException - thrown if, and only if, either list or function are null, or function returns nullpublic static <T> int[] toIntArray(java.util.List<T> list,
java.util.function.Function<T,int[]> function,
int minimumLength)
int[] by merging smaller int[] together.
If either list or function are null, or function returns null, a NullPointerException will be thrown.
If an element in list is null, a NullPointerException might be thrown. But no guarantees can be made. This is up to function.
If the length of the larger int[] is less than minimumLength, a new empty int[] with minimumLength as length will be returned.
T - the generic type to uselist - a Listfunction - a Function mapping Lists elements to int[]minimumLength - the minimum length of the int[] to returnint[] by merging smaller int[] togetherjava.lang.NullPointerException - thrown if, and only if, either list or function are null, or function returns nullpublic static void writeFloatArray(java.io.DataOutputStream dataOutputStream,
float[] array)
throws java.io.IOException
float values of array into dataOutputStream.
If either dataOutputStream or array are null, a NullPointerException will be thrown.
If an I/O error occurs, an IOException will be thrown.
dataOutputStream - the DataOutputStream to write toarray - the float[] with the float values to write to dataOutputStreamjava.io.IOException - thrown if, and only if, an I/O error occursjava.lang.NullPointerException - thrown if, and only if, either dataOutputStream or array are nullpublic static void writeIntArray(java.io.DataOutputStream dataOutputStream,
int[] array)
throws java.io.IOException
int values of array into dataOutputStream.
If either dataOutputStream or array are null, a NullPointerException will be thrown.
If an I/O error occurs, an IOException will be thrown.
dataOutputStream - the DataOutputStream to write toarray - the int[] with the int values to write to dataOutputStreamjava.io.IOException - thrown if, and only if, an I/O error occursjava.lang.NullPointerException - thrown if, and only if, either dataOutputStream or array are null