# HG changeset patch # User chegar # Date 1425060727 0 # Node ID a9f00e8ae58b2ba378e0de64f6192cc2d3e8c49a # Parent be92cc7636f8ea8d51099cf7bcad468f5d2c6fd4 8074043: java.util.Arrays setAll and parallelSetAll subrange note Reviewed-by: smarks diff -r be92cc7636f8 -r a9f00e8ae58b jdk/src/java.base/share/classes/java/util/Arrays.java --- a/jdk/src/java.base/share/classes/java/util/Arrays.java Fri Feb 27 10:09:06 2015 -0500 +++ b/jdk/src/java.base/share/classes/java/util/Arrays.java Fri Feb 27 18:12:07 2015 +0000 @@ -4685,6 +4685,14 @@ *

If the generator function throws an exception, it is relayed to * the caller and the array is left in an indeterminate state. * + * @apiNote + * Setting a subrange of an array, using a generator function to compute + * each element, can be written as follows: + *

{@code
+     * IntStream.range(startInclusive, endExclusive)
+     *          .forEach(i -> array[i] = generator.apply(i));
+     * }
+ * * @param type of elements of the array * @param array array to be initialized * @param generator a function accepting an index and producing the desired @@ -4706,6 +4714,15 @@ * is thrown from {@code parallelSetAll} and the array is left in an * indeterminate state. * + * @apiNote + * Setting a subrange of an array, in parallel, using a generator function + * to compute each element, can be written as follows: + *
{@code
+     * IntStream.range(startInclusive, endExclusive)
+     *          .parallel()
+     *          .forEach(i -> array[i] = generator.apply(i));
+     * }
+ * * @param type of elements of the array * @param array array to be initialized * @param generator a function accepting an index and producing the desired @@ -4725,6 +4742,14 @@ *

If the generator function throws an exception, it is relayed to * the caller and the array is left in an indeterminate state. * + * @apiNote + * Setting a subrange of an array, using a generator function to compute + * each element, can be written as follows: + *

{@code
+     * IntStream.range(startInclusive, endExclusive)
+     *          .forEach(i -> array[i] = generator.applyAsInt(i));
+     * }
+ * * @param array array to be initialized * @param generator a function accepting an index and producing the desired * value for that position @@ -4745,6 +4770,15 @@ * is thrown from {@code parallelSetAll} and the array is left in an * indeterminate state. * + * @apiNote + * Setting a subrange of an array, in parallel, using a generator function + * to compute each element, can be written as follows: + *
{@code
+     * IntStream.range(startInclusive, endExclusive)
+     *          .parallel()
+     *          .forEach(i -> array[i] = generator.applyAsInt(i));
+     * }
+ * * @param array array to be initialized * @param generator a function accepting an index and producing the desired * value for that position @@ -4763,6 +4797,14 @@ *

If the generator function throws an exception, it is relayed to * the caller and the array is left in an indeterminate state. * + * @apiNote + * Setting a subrange of an array, using a generator function to compute + * each element, can be written as follows: + *

{@code
+     * IntStream.range(startInclusive, endExclusive)
+     *          .forEach(i -> array[i] = generator.applyAsLong(i));
+     * }
+ * * @param array array to be initialized * @param generator a function accepting an index and producing the desired * value for that position @@ -4783,6 +4825,15 @@ * is thrown from {@code parallelSetAll} and the array is left in an * indeterminate state. * + * @apiNote + * Setting a subrange of an array, in parallel, using a generator function + * to compute each element, can be written as follows: + *
{@code
+     * IntStream.range(startInclusive, endExclusive)
+     *          .parallel()
+     *          .forEach(i -> array[i] = generator.applyAsLong(i));
+     * }
+ * * @param array array to be initialized * @param generator a function accepting an index and producing the desired * value for that position @@ -4801,6 +4852,14 @@ *

If the generator function throws an exception, it is relayed to * the caller and the array is left in an indeterminate state. * + * @apiNote + * Setting a subrange of an array, using a generator function to compute + * each element, can be written as follows: + *

{@code
+     * IntStream.range(startInclusive, endExclusive)
+     *          .forEach(i -> array[i] = generator.applyAsDouble(i));
+     * }
+ * * @param array array to be initialized * @param generator a function accepting an index and producing the desired * value for that position @@ -4821,6 +4880,15 @@ * is thrown from {@code parallelSetAll} and the array is left in an * indeterminate state. * + * @apiNote + * Setting a subrange of an array, in parallel, using a generator function + * to compute each element, can be written as follows: + *
{@code
+     * IntStream.range(startInclusive, endExclusive)
+     *          .parallel()
+     *          .forEach(i -> array[i] = generator.applyAsDouble(i));
+     * }
+ * * @param array array to be initialized * @param generator a function accepting an index and producing the desired * value for that position