RFR: 8294693: Add Collections.shuffle overload that accepts RandomGenerator interface [v3]

Tagir F. Valeev tvaleev at openjdk.org
Wed Oct 12 13:26:29 UTC 2022


> Java 17 added RandomGenerator interface. However, existing method Collections.shuffle accepts old java.util.Random class. While since Java 19, it's possible to use Random.from(RandomGenerator) wrapper, it would be more convenient to provide direct overload shuffle(List<?> list, RandomGenerator rnd).

Tagir F. Valeev has updated the pull request incrementally with one additional commit since the last revision:

  Fixes according to review
  
  1. Reduce duplication in tests
  2. Use JumpableGenerator#copy() instead of create(1) in tests, as according to the spec, seed can be ignored
  3. Simplify documentation for shuffle(List, Random) to avoid duplication.

-------------

Changes:
  - all: https://git.openjdk.org/jdk/pull/10520/files
  - new: https://git.openjdk.org/jdk/pull/10520/files/6fa7d942..127e44ca

Webrevs:
 - full: https://webrevs.openjdk.org/?repo=jdk&pr=10520&range=02
 - incr: https://webrevs.openjdk.org/?repo=jdk&pr=10520&range=01-02

  Stats: 38 lines in 2 files changed: 2 ins; 26 del; 10 mod
  Patch: https://git.openjdk.org/jdk/pull/10520.diff
  Fetch: git fetch https://git.openjdk.org/jdk pull/10520/head:pull/10520

PR: https://git.openjdk.org/jdk/pull/10520


More information about the core-libs-dev mailing list