Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8074043

java.util.Arrays setAll and parallelSetAll subrange note

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • P3
    • 9
    • 9
    • core-libs
    • b54

    Backports

      Description

        It came up recently that java.util.Arrays was missing subrange overloads for setAll and parallelSetAll. These methods can be easily written with IntStream.range. Rather than adding eight new methods for this, it makes sense to point developers to IntStream.range. It seems reasonable to add a small note to these methods, promoting the use of IntStream. If someone is hunting around for a subrange setAll, then they will inevitable end up seeing this note. For example:

        + * @apiNote
        + * Setting a subrange of an array, using a generator function to compute
        + * each element, can be written as follows:
        + * <pre>{@code
        + * IntStream.range(startInclusive, endExclusive)
        + * .forEach(i -> array[i] = generator.apply(i));
        + * }</pre>
        + *

        Attachments

          Issue Links

            Activity

              People

                chegar Chris Hegarty
                chegar Chris Hegarty
                Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                  Created:
                  Updated:
                  Resolved: