Top Description Constructors Methods
org.apache.commons.lang3

public final Class ArrayFill

extends Object
Class Inheritance
Imports
java.util.Arrays, java.util.function.IntFunction, org.apache.commons.lang3.function.FailableIntFunction

Fills and returns arrays in the fluent style.
Since
3.14.0

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static boolean[]

Returns:

the given array.
fill
(final boolean[]
the array to be filled (may be null).
a
,
final boolean
the value to be stored in all elements of the array.
val
)

Fills and returns the given array, assigning the given boolean value to each element of the array.

public static byte[]

Returns:

the given array.
fill
(final byte[]
the array to be filled (may be null).
a
,
final byte
the value to be stored in all elements of the array.
val
)

Fills and returns the given array, assigning the given byte value to each element of the array.

public static char[]

Returns:

the given array.
fill
(final char[]
the array to be filled (may be null).
a
,
final char
the value to be stored in all elements of the array.
val
)

Fills and returns the given array, assigning the given char value to each element of the array.

public static double[]

Returns:

the given array.
fill
(final double[]
the array to be filled (may be null).
a
,
final double
the value to be stored in all elements of the array.
val
)

Fills and returns the given array, assigning the given double value to each element of the array.

public static float[]

Returns:

the given array.
fill
(final float[]
the array to be filled (may be null).
a
,
final float
the value to be stored in all elements of the array.
val
)

Fills and returns the given array, assigning the given float value to each element of the array.

public static int[]

Returns:

the given array.
fill
(final int[]
the array to be filled (may be null).
a
,
final int
the value to be stored in all elements of the array.
val
)

Fills and returns the given array, assigning the given int value to each element of the array.

public static long[]

Returns:

the given array.
fill
(final long[]
the array to be filled (may be null).
a
,
final long
the value to be stored in all elements of the array.
val
)

Fills and returns the given array, assigning the given long value to each element of the array.

public static short[]

Returns:

the given array.
fill
(final short[]
the array to be filled (may be null).
a
,
final short
the value to be stored in all elements of the array.
val
)

Fills and returns the given array, assigning the given short value to each element of the array.

public static <
type of elements of the array.
T
,
The kind of thrown exception or error.
E extends Throwable
>
T[]

Returns:

the input array
fill
(final T[]
array to be initialized.
array
,
final FailableIntFunction<? extends T, E>
a function accepting an index and producing the desired value for that position.
generator
)

Fills and returns the given array, using the provided generator supplier to compute each element.

public static <
the array type.
T
>
T[]

Returns:

the given array.
fill
(final T[]
the array to be filled (may be null).
a
,
final T
the value to be stored in all elements of the array.
val
)

Fills and returns the given array, assigning the given T value to each element of the array.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

ArrayFillback to summary
private ArrayFill()

Method Detail

fillback to summary
public static boolean[] fill(final boolean[] a, final boolean val)

Fills and returns the given array, assigning the given boolean value to each element of the array.

Parameters
a:boolean[]

the array to be filled (may be null).

val:boolean

the value to be stored in all elements of the array.

Returns:boolean[]

the given array.

Since
3.18.0
See Also
Arrays#fill(boolean[], boolean)
fillback to summary
public static byte[] fill(final byte[] a, final byte val)

Fills and returns the given array, assigning the given byte value to each element of the array.

Parameters
a:byte[]

the array to be filled (may be null).

val:byte

the value to be stored in all elements of the array.

Returns:byte[]

the given array.

See Also
Arrays#fill(byte[], byte)
fillback to summary
public static char[] fill(final char[] a, final char val)

Fills and returns the given array, assigning the given char value to each element of the array.

Parameters
a:char[]

the array to be filled (may be null).

val:char

the value to be stored in all elements of the array.

Returns:char[]

the given array.

See Also
Arrays#fill(char[], char)
fillback to summary
public static double[] fill(final double[] a, final double val)

Fills and returns the given array, assigning the given double value to each element of the array.

Parameters
a:double[]

the array to be filled (may be null).

val:double

the value to be stored in all elements of the array.

Returns:double[]

the given array.

See Also
Arrays#fill(double[], double)
fillback to summary
public static float[] fill(final float[] a, final float val)

Fills and returns the given array, assigning the given float value to each element of the array.

Parameters
a:float[]

the array to be filled (may be null).

val:float

the value to be stored in all elements of the array.

Returns:float[]

the given array.

See Also
Arrays#fill(float[], float)
fillback to summary
public static int[] fill(final int[] a, final int val)

Fills and returns the given array, assigning the given int value to each element of the array.

Parameters
a:int[]

the array to be filled (may be null).

val:int

the value to be stored in all elements of the array.

Returns:int[]

the given array.

See Also
Arrays#fill(int[], int)
fillback to summary
public static long[] fill(final long[] a, final long val)

Fills and returns the given array, assigning the given long value to each element of the array.

Parameters
a:long[]

the array to be filled (may be null).

val:long

the value to be stored in all elements of the array.

Returns:long[]

the given array.

See Also
Arrays#fill(long[], long)
fillback to summary
public static short[] fill(final short[] a, final short val)

Fills and returns the given array, assigning the given short value to each element of the array.

Parameters
a:short[]

the array to be filled (may be null).

val:short

the value to be stored in all elements of the array.

Returns:short[]

the given array.

See Also
Arrays#fill(short[], short)
fillback to summary
public static <T, E extends Throwable> T[] fill(final T[] array, final FailableIntFunction<? extends T, E> generator) throws FailableIntFunction:E

Fills and returns the given array, using the provided generator supplier to compute each element. Like Arrays#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.

Parameters
<T>
type of elements of the array.
<E>
The kind of thrown exception or error.
array:T[]

array to be initialized.

generator:FailableIntFunction<? extends T, E>

a function accepting an index and producing the desired value for that position.

Returns:T[]

the input array

Exceptions
FailableIntFunction:E:
Thrown by the given generator.
Since
3.18.0
See Also
Arrays#setAll(Object[], IntFunction)
fillback to summary
public static <T> T[] fill(final T[] a, final T val)

Fills and returns the given array, assigning the given T value to each element of the array.

Parameters
<T>
the array type.
a:T[]

the array to be filled (may be null).

val:T

the value to be stored in all elements of the array.

Returns:T[]

the given array.

See Also
Arrays#fill(Object[], Object)