Package org.apache.commons.lang3
Class ArrayFill
- java.lang.Object
-
- org.apache.commons.lang3.ArrayFill
-
public final class ArrayFill extends java.lang.Object
Fills and returns arrays in the fluent style.- Since:
- 3.14.0
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static boolean[]
fill(boolean[] a, boolean val)
Fills and returns the given array, assigning the givenboolean
value to each element of the array.static byte[]
fill(byte[] a, byte val)
Fills and returns the given array, assigning the givenbyte
value to each element of the array.static char[]
fill(char[] a, char val)
Fills and returns the given array, assigning the givenchar
value to each element of the array.static double[]
fill(double[] a, double val)
Fills and returns the given array, assigning the givendouble
value to each element of the array.static float[]
fill(float[] a, float val)
Fills and returns the given array, assigning the givenfloat
value to each element of the array.static int[]
fill(int[] a, int val)
Fills and returns the given array, assigning the givenint
value to each element of the array.static long[]
fill(long[] a, long val)
Fills and returns the given array, assigning the givenlong
value to each element of the array.static short[]
fill(short[] a, short val)
Fills and returns the given array, assigning the givenshort
value to each element of the array.static <T,E extends java.lang.Throwable>
T[]fill(T[] array, FailableIntFunction<? extends T,E> generator)
Fills and returns the given array, using the provided generator supplier to compute each element.static <T> T[]
fill(T[] a, T val)
Fills and returns the given array, assigning the givenT
value to each element of the array.
-
-
-
Method Detail
-
fill
public static boolean[] fill(boolean[] a, boolean val)
Fills and returns the given array, assigning the givenboolean
value to each element of the array.- Parameters:
a
- the array to be filled (may be null).val
- the value to be stored in all elements of the array.- Returns:
- the given array.
- Since:
- 3.18.0
- See Also:
Arrays.fill(boolean[],boolean)
-
fill
public static byte[] fill(byte[] a, byte val)
Fills and returns the given array, assigning the givenbyte
value to each element of the array.- Parameters:
a
- the array to be filled (may be null).val
- the value to be stored in all elements of the array.- Returns:
- the given array.
- See Also:
Arrays.fill(byte[],byte)
-
fill
public static char[] fill(char[] a, char val)
Fills and returns the given array, assigning the givenchar
value to each element of the array.- Parameters:
a
- the array to be filled (may be null).val
- the value to be stored in all elements of the array.- Returns:
- the given array.
- See Also:
Arrays.fill(char[],char)
-
fill
public static double[] fill(double[] a, double val)
Fills and returns the given array, assigning the givendouble
value to each element of the array.- Parameters:
a
- the array to be filled (may be null).val
- the value to be stored in all elements of the array.- Returns:
- the given array.
- See Also:
Arrays.fill(double[],double)
-
fill
public static float[] fill(float[] a, float val)
Fills and returns the given array, assigning the givenfloat
value to each element of the array.- Parameters:
a
- the array to be filled (may be null).val
- the value to be stored in all elements of the array.- Returns:
- the given array.
- See Also:
Arrays.fill(float[],float)
-
fill
public static int[] fill(int[] a, int val)
Fills and returns the given array, assigning the givenint
value to each element of the array.- Parameters:
a
- the array to be filled (may be null).val
- the value to be stored in all elements of the array.- Returns:
- the given array.
- See Also:
Arrays.fill(int[],int)
-
fill
public static long[] fill(long[] a, long val)
Fills and returns the given array, assigning the givenlong
value to each element of the array.- Parameters:
a
- the array to be filled (may be null).val
- the value to be stored in all elements of the array.- Returns:
- the given array.
- See Also:
Arrays.fill(long[],long)
-
fill
public static short[] fill(short[] a, short val)
Fills and returns the given array, assigning the givenshort
value to each element of the array.- Parameters:
a
- the array to be filled (may be null).val
- the value to be stored in all elements of the array.- Returns:
- the given array.
- See Also:
Arrays.fill(short[],short)
-
fill
public static <T,E extends java.lang.Throwable> T[] fill(T[] array, FailableIntFunction<? extends T,E> generator) throws E extends java.lang.Throwable
Fills and returns the given array, using the provided generator supplier to compute each element. LikeArrays.setAll(Object[], IntFunction)
with exception support.If the generator supplier throws an exception, it is relayed to the caller and the array is left in an indeterminate state.
- Type Parameters:
T
- type of elements of the array.E
- The kind of thrown exception or error.- Parameters:
array
- array to be initialized.generator
- a function accepting an index and producing the desired value for that position.- Returns:
- the input array
- Throws:
E
- Thrown by the givengenerator
.E extends java.lang.Throwable
- Since:
- 3.18.0
- See Also:
Arrays.setAll(Object[], IntFunction)
-
fill
public static <T> T[] fill(T[] a, T val)
Fills and returns the given array, assigning the givenT
value to each element of the array.- Type Parameters:
T
- the array type.- Parameters:
a
- the array to be filled (may be null).val
- the value to be stored in all elements of the array.- Returns:
- the given array.
- See Also:
Arrays.fill(Object[],Object)
-
-