Hello Alex.

>>> [...]
>
> OK so this results in:
>
> /**
>   * Some summary.
>   */
> public interface JumpableUniformRandomProvider extends
> UniformRandomProvider {
>      /**
>       * Creates a copy of the UniformRandomProvider and advances the
> state of the copy.
>       * The state of the current instance is not altered. The state of
> the copy will be
>       * advanced an equivalent of {@code n} sequential calls to a method
> that updates the
>       * state of the provider.
>       *
>       * @return the copy with an advanced state
>       */
>      JumpableUniformRandomProvider jump();
> }
>

+1
[Clean and lean: and no side-effects to explain...]

>
> This can be documented in an implementation as:
>
> public class MyJumpingRNG implements JumpableUniformRandomProvider {
>      /**
>       * {@inheritDoc}
>       *
>       * <p>The jump size {@code n} is the equivalent of {@code 2^64}
> calls to
>       * {@link UniformRandomProvider#nextLong() nextLong()}.
>       */
>      @Override
>      public JumpableUniformRandomProvider jump() {
>          // TODO Auto-generated method stub
>          return null;
>      }
> }

+1

>
> Do we add a second interface for LongJumpableUniformRandomProvider?

Sure, if the functionality is provided by some of the algorithms implemented
in [RNG].
But let's have the two functionalities in separate commits.

>
> >> So the options are (in all cases returning the copy):
> >>
> >> 1. createAndJumpCopy
> >> 2. copyAndJumpParent
> >> 3. jumpParentAndCopy
> >> 4. jump and copy separately
> >>
> >> 1. Your preferred option. A copy of the state is made. The state is 
> >> advanced in the copy and returned. But when called repeatedly it will get 
> >> the same generator and code must be organised appropriately.
> > We could provide a convenience method in  "RandomSource":
> >
> > public UniformRandomProvider[] jump(int n,
> > JumpableUniformRandomProvider parent) {
> >      final UniformRandomProvider[] rngs = new UniformRandomProvider[n];
> >      UniformRandomProvider tmp = parent;
> >      for (int i = 0; i < n; i++) {
> >          rngs[i] = restrict(tmp);
> >          tmp = tmp.jump();
> >      }
> >      return rngs;
> > }
>
> +1. Remove the need for the user to repeat boiler plate code.
>
> Same sort of idea of longJump() too.

+1

> >> It is not actually possible to jump forward a single instance. Only 
> >> children are advanced.
> > A feature: There is only one way to alter the state of an instance
> > (i.e. a call to "next()").
> OK.

Great. :-)

Gilles

> >
>>> [...]

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@commons.apache.org
For additional commands, e-mail: dev-h...@commons.apache.org

Reply via email to