Javadoc de Arrays.setAll

Lien vers une javadoc complète.

setAll

public static void setAll​(int[] array, IntUnaryOperator generator)
Set all elements of the specified array, using the provided generator function to compute each element.

If the generator function throws an exception, it is relayed to the caller and the array is left in an indeterminate state.

API Note:
Setting a subrange of an array, using a generator function to compute each element, can be written as follows:
   IntStream.range(startInclusive, endExclusive)
.forEach(i -> array[i] = generator.applyAsInt(i));
Parameters:
array - array to be initialized
generator - a function accepting an index and producing the desired value for that position
Throws:
NullPointerException - if the generator is null
Since:
1.8

Javadoc de IntUnaryOperator

Module java.base
Package java.util.function

Interface IntUnaryOperator

Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
@FunctionalInterface
public interface IntUnaryOperator
Represents an operation on a single int-valued operand that produces an int-valued result. This is the primitive type specialization of UnaryOperator for int.

This is a functional interface whose functional method is applyAsInt(int).

Since:
1.8
See Also:
UnaryOperator