[ 
https://issues.apache.org/jira/browse/RNG-189?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18057570#comment-18057570
 ] 

Alex Herbert edited comment on RNG-189 at 2/10/26 12:53 PM:
------------------------------------------------------------

This interface can be supported by the counter based Philox RNGs (see 
[RNG-188]).


was (Author: alexherbert):
This interface can be supported by the counter based Philox RNGs (see [RNG 
188]).

> Add interface ArbitrarilyJumpableGenerator
> ------------------------------------------
>
>                 Key: RNG-189
>                 URL: https://issues.apache.org/jira/browse/RNG-189
>             Project: Commons RNG
>          Issue Type: New Feature
>          Components: client-api
>            Reporter: Alex Herbert
>            Priority: Minor
>
> Add an interface to allow a generator to jump an arbitrary distance in its 
> output period.
> This would be the equivalent of the interface from JDK 17+ 
> {{java.util.random}} package:
> [RandomGenerator.ArbitrarilyJumpableGenerator (Javadoc JDK 
> 25)|https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/util/random/RandomGenerator.ArbitrarilyJumpableGenerator.html]
> The jump distance in that interface is specified as a double to avoid the use 
> of BigInteger for large jump distances. The JDK interfaces specify copy, jump 
> and copyAndJump. However Commons RNG does not support easy copying of a 
> generator to avoid common pitfalls of outputting the same sequence in 
> multiple threads via a copy.
> The simplest API would be similar to the Commons RNG Jumpable interface with 
> the addition of a distance argument:
> {code:java}
> public interface ArbitrarilyJumpableUniformRandomProvider extends 
> UniformRandomProvider {
>     ArbitrarilyJumpableUniformRandomProvider jump(double distance);
>     default Stream<UniformRandomProvider> jumps(double distance) {
>         // ...
>     }
>     default Stream<UniformRandomProvider> jumps(long streamSize, double 
> distance) {
>         // ...
>     }
> }
> {code}
> Note that the return value of a generator from the jump method makes this 
> interface incompatible with the JDK's which returns void. However the 
> existing Commons RNG jumping interfaces, which predate the JDK 17 release, 
> are also incompatible. Any future update with minimum Java 17 support will 
> have to address compatibility.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to