jdk/src/java.base/share/classes/java/util/Arrays.java
changeset 29223 a9f00e8ae58b
parent 28059 e576535359cc
child 31671 362e0c0acece
child 31540 6efd719b3330
equal deleted inserted replaced
29222:be92cc7636f8 29223:a9f00e8ae58b
  4683      * generator function to compute each element.
  4683      * generator function to compute each element.
  4684      *
  4684      *
  4685      * <p>If the generator function throws an exception, it is relayed to
  4685      * <p>If the generator function throws an exception, it is relayed to
  4686      * the caller and the array is left in an indeterminate state.
  4686      * the caller and the array is left in an indeterminate state.
  4687      *
  4687      *
       
  4688      * @apiNote
       
  4689      * Setting a subrange of an array, using a generator function to compute
       
  4690      * each element, can be written as follows:
       
  4691      * <pre>{@code
       
  4692      * IntStream.range(startInclusive, endExclusive)
       
  4693      *          .forEach(i -> array[i] = generator.apply(i));
       
  4694      * }</pre>
       
  4695      *
  4688      * @param <T> type of elements of the array
  4696      * @param <T> type of elements of the array
  4689      * @param array array to be initialized
  4697      * @param array array to be initialized
  4690      * @param generator a function accepting an index and producing the desired
  4698      * @param generator a function accepting an index and producing the desired
  4691      *        value for that position
  4699      *        value for that position
  4692      * @throws NullPointerException if the generator is null
  4700      * @throws NullPointerException if the generator is null
  4704      *
  4712      *
  4705      * <p>If the generator function throws an exception, an unchecked exception
  4713      * <p>If the generator function throws an exception, an unchecked exception
  4706      * is thrown from {@code parallelSetAll} and the array is left in an
  4714      * is thrown from {@code parallelSetAll} and the array is left in an
  4707      * indeterminate state.
  4715      * indeterminate state.
  4708      *
  4716      *
       
  4717      * @apiNote
       
  4718      * Setting a subrange of an array, in parallel, using a generator function
       
  4719      * to compute each element, can be written as follows:
       
  4720      * <pre>{@code
       
  4721      * IntStream.range(startInclusive, endExclusive)
       
  4722      *          .parallel()
       
  4723      *          .forEach(i -> array[i] = generator.apply(i));
       
  4724      * }</pre>
       
  4725      *
  4709      * @param <T> type of elements of the array
  4726      * @param <T> type of elements of the array
  4710      * @param array array to be initialized
  4727      * @param array array to be initialized
  4711      * @param generator a function accepting an index and producing the desired
  4728      * @param generator a function accepting an index and producing the desired
  4712      *        value for that position
  4729      *        value for that position
  4713      * @throws NullPointerException if the generator is null
  4730      * @throws NullPointerException if the generator is null
  4723      * generator function to compute each element.
  4740      * generator function to compute each element.
  4724      *
  4741      *
  4725      * <p>If the generator function throws an exception, it is relayed to
  4742      * <p>If the generator function throws an exception, it is relayed to
  4726      * the caller and the array is left in an indeterminate state.
  4743      * the caller and the array is left in an indeterminate state.
  4727      *
  4744      *
       
  4745      * @apiNote
       
  4746      * Setting a subrange of an array, using a generator function to compute
       
  4747      * each element, can be written as follows:
       
  4748      * <pre>{@code
       
  4749      * IntStream.range(startInclusive, endExclusive)
       
  4750      *          .forEach(i -> array[i] = generator.applyAsInt(i));
       
  4751      * }</pre>
       
  4752      *
  4728      * @param array array to be initialized
  4753      * @param array array to be initialized
  4729      * @param generator a function accepting an index and producing the desired
  4754      * @param generator a function accepting an index and producing the desired
  4730      *        value for that position
  4755      *        value for that position
  4731      * @throws NullPointerException if the generator is null
  4756      * @throws NullPointerException if the generator is null
  4732      * @since 1.8
  4757      * @since 1.8
  4743      *
  4768      *
  4744      * <p>If the generator function throws an exception, an unchecked exception
  4769      * <p>If the generator function throws an exception, an unchecked exception
  4745      * is thrown from {@code parallelSetAll} and the array is left in an
  4770      * is thrown from {@code parallelSetAll} and the array is left in an
  4746      * indeterminate state.
  4771      * indeterminate state.
  4747      *
  4772      *
       
  4773      * @apiNote
       
  4774      * Setting a subrange of an array, in parallel, using a generator function
       
  4775      * to compute each element, can be written as follows:
       
  4776      * <pre>{@code
       
  4777      * IntStream.range(startInclusive, endExclusive)
       
  4778      *          .parallel()
       
  4779      *          .forEach(i -> array[i] = generator.applyAsInt(i));
       
  4780      * }</pre>
       
  4781      *
  4748      * @param array array to be initialized
  4782      * @param array array to be initialized
  4749      * @param generator a function accepting an index and producing the desired
  4783      * @param generator a function accepting an index and producing the desired
  4750      * value for that position
  4784      * value for that position
  4751      * @throws NullPointerException if the generator is null
  4785      * @throws NullPointerException if the generator is null
  4752      * @since 1.8
  4786      * @since 1.8
  4761      * generator function to compute each element.
  4795      * generator function to compute each element.
  4762      *
  4796      *
  4763      * <p>If the generator function throws an exception, it is relayed to
  4797      * <p>If the generator function throws an exception, it is relayed to
  4764      * the caller and the array is left in an indeterminate state.
  4798      * the caller and the array is left in an indeterminate state.
  4765      *
  4799      *
       
  4800      * @apiNote
       
  4801      * Setting a subrange of an array, using a generator function to compute
       
  4802      * each element, can be written as follows:
       
  4803      * <pre>{@code
       
  4804      * IntStream.range(startInclusive, endExclusive)
       
  4805      *          .forEach(i -> array[i] = generator.applyAsLong(i));
       
  4806      * }</pre>
       
  4807      *
  4766      * @param array array to be initialized
  4808      * @param array array to be initialized
  4767      * @param generator a function accepting an index and producing the desired
  4809      * @param generator a function accepting an index and producing the desired
  4768      *        value for that position
  4810      *        value for that position
  4769      * @throws NullPointerException if the generator is null
  4811      * @throws NullPointerException if the generator is null
  4770      * @since 1.8
  4812      * @since 1.8
  4781      *
  4823      *
  4782      * <p>If the generator function throws an exception, an unchecked exception
  4824      * <p>If the generator function throws an exception, an unchecked exception
  4783      * is thrown from {@code parallelSetAll} and the array is left in an
  4825      * is thrown from {@code parallelSetAll} and the array is left in an
  4784      * indeterminate state.
  4826      * indeterminate state.
  4785      *
  4827      *
       
  4828      * @apiNote
       
  4829      * Setting a subrange of an array, in parallel, using a generator function
       
  4830      * to compute each element, can be written as follows:
       
  4831      * <pre>{@code
       
  4832      * IntStream.range(startInclusive, endExclusive)
       
  4833      *          .parallel()
       
  4834      *          .forEach(i -> array[i] = generator.applyAsLong(i));
       
  4835      * }</pre>
       
  4836      *
  4786      * @param array array to be initialized
  4837      * @param array array to be initialized
  4787      * @param generator a function accepting an index and producing the desired
  4838      * @param generator a function accepting an index and producing the desired
  4788      *        value for that position
  4839      *        value for that position
  4789      * @throws NullPointerException if the generator is null
  4840      * @throws NullPointerException if the generator is null
  4790      * @since 1.8
  4841      * @since 1.8
  4799      * generator function to compute each element.
  4850      * generator function to compute each element.
  4800      *
  4851      *
  4801      * <p>If the generator function throws an exception, it is relayed to
  4852      * <p>If the generator function throws an exception, it is relayed to
  4802      * the caller and the array is left in an indeterminate state.
  4853      * the caller and the array is left in an indeterminate state.
  4803      *
  4854      *
       
  4855      * @apiNote
       
  4856      * Setting a subrange of an array, using a generator function to compute
       
  4857      * each element, can be written as follows:
       
  4858      * <pre>{@code
       
  4859      * IntStream.range(startInclusive, endExclusive)
       
  4860      *          .forEach(i -> array[i] = generator.applyAsDouble(i));
       
  4861      * }</pre>
       
  4862      *
  4804      * @param array array to be initialized
  4863      * @param array array to be initialized
  4805      * @param generator a function accepting an index and producing the desired
  4864      * @param generator a function accepting an index and producing the desired
  4806      *        value for that position
  4865      *        value for that position
  4807      * @throws NullPointerException if the generator is null
  4866      * @throws NullPointerException if the generator is null
  4808      * @since 1.8
  4867      * @since 1.8
  4818      * provided generator function to compute each element.
  4877      * provided generator function to compute each element.
  4819      *
  4878      *
  4820      * <p>If the generator function throws an exception, an unchecked exception
  4879      * <p>If the generator function throws an exception, an unchecked exception
  4821      * is thrown from {@code parallelSetAll} and the array is left in an
  4880      * is thrown from {@code parallelSetAll} and the array is left in an
  4822      * indeterminate state.
  4881      * indeterminate state.
       
  4882      *
       
  4883      * @apiNote
       
  4884      * Setting a subrange of an array, in parallel, using a generator function
       
  4885      * to compute each element, can be written as follows:
       
  4886      * <pre>{@code
       
  4887      * IntStream.range(startInclusive, endExclusive)
       
  4888      *          .parallel()
       
  4889      *          .forEach(i -> array[i] = generator.applyAsDouble(i));
       
  4890      * }</pre>
  4823      *
  4891      *
  4824      * @param array array to be initialized
  4892      * @param array array to be initialized
  4825      * @param generator a function accepting an index and producing the desired
  4893      * @param generator a function accepting an index and producing the desired
  4826      *        value for that position
  4894      *        value for that position
  4827      * @throws NullPointerException if the generator is null
  4895      * @throws NullPointerException if the generator is null