Class EnhancedJumpableGenerator

All Implemented Interfaces:
RandomGenerator, RandomGenerator.JumpableGenerator, RandomGenerator.StreamableGenerator
Direct Known Subclasses:
EnhancedLeapableGenerator

public class EnhancedJumpableGenerator extends EnhancedStreamableGenerator implements RandomGenerator.JumpableGenerator

An EnhancedJumpableGenerator is used to wrap an object of any class that implements RandomGenerator.JumpableGenerator for the purpose of adding all of the functionality of the RandomIndexer and RandomVariates. See the superclass EnhancedRandomGenerator for documentation of the enhanced functionality that is added to the wrapped object.

The methods of the RandomGenerator.JumpableGenerator interface, such as jumps(), that return streams of RandomGenerator are implemented to return streams of EnhancedRandomGenerator objects that wrap the RandomGenerator objects in the streams returned by the enclosed RandomGenerator.JumpableGenerator. However, additionally this class provides a counterpart, such as ejumps(), for each of these methods whose return type is explicitly a stream of EnhancedRandomGenerator objects to simplify usage without the need to cast the objects of the stream in order to utilize the enhancements.

  • Constructor Details

  • Method Details

    • of

      public static EnhancedJumpableGenerator of(String algorithmName)
      Gets an EnhancedJumpableGenerator wrapping an instance of any random number generator supported by your version of Java as specified by its name, as documented via the RandomGenerator.JumpableGenerator.of(java.lang.String) method.
      Parameters:
      algorithmName - The name of the random number generator as documented by the RandomGenerator.JumpableGenerator.of(java.lang.String) method.
      Returns:
      an EnhancedJumpableGenerator wrapping an instance of your chosen random number generator.
      Throws:
      NullPointerException - if algorithmName is null.
      IllegalArgumentException - if algorithmName is not found.
    • copy

      Creates and returns a new EnhancedJumpableGenerator whose internal state is an exact copy of this one. Thus, if subjected to the same series of actions, this EnhancedJumpableGenerator and its copy should behave identically.
      Specified by:
      copy in interface RandomGenerator.JumpableGenerator
      Returns:
      a new EnhancedJumpableGenerator with internal state identical to this one.
    • copyAndJump

      public final EnhancedJumpableGenerator copyAndJump()
      Creates a copy of this EnhancedJumpableGenerator, jumps this EnhancedJumpableGenerator forward, and then returns the copy.
      Specified by:
      copyAndJump in interface RandomGenerator.JumpableGenerator
      Returns:
      a copy of this EnhancedJumpableGenerator before the jump occurred.
    • jump

      public final void jump()
      Changes the state of this EnhancedJumpableGenerator to jump a large fixed distance, indicated by the jumpDistance() method, in its state cycle.
      Specified by:
      jump in interface RandomGenerator.JumpableGenerator
    • jumpDistance

      public final double jumpDistance()
      Returns the distance by which the jump() method will jump ahead in this EnhancedJumpableGenerator instance's state cycle.
      Specified by:
      jumpDistance in interface RandomGenerator.JumpableGenerator
      Returns:
      the jump distance
    • ejumps

      public final Stream<EnhancedRandomGenerator> ejumps()

      Gets an effectively unlimited stream of EnhancedRandomGenerator objects, each wrapping an object of the same random number generator algorithm as this one. The random number generators in the stream are not also jumpable.

      The behavior of this method is identical to that of jumps(), but may be more convenient to use due to explicit return type of a stream of EnhancedRandomGenerator objects.

      Returns:
      a stream of EnhancedRandomGenerator objects
    • ejumps

      public final Stream<EnhancedRandomGenerator> ejumps(long streamSize)

      Gets a stream of EnhancedRandomGenerator objects, each wrapping an object of the same random number generator algorithm as this one. The random number generators in the stream are not also jumpable.

      The behavior of this method is identical to that of jumps(long), but may be more convenient to use due to explicit return type of a stream of EnhancedRandomGenerator objects.

      Parameters:
      streamSize - the number of EnhancedRandomGenerator objects in the stream
      Returns:
      a stream of EnhancedRandomGenerator objects
    • jumps

      public final Stream<RandomGenerator> jumps()

      Gets an effectively unlimited stream of EnhancedRandomGenerator objects, each wrapping an object of the same random number generator algorithm as this one. The random number generators in the stream are not also jumpable.

      The implementation of this method from the RandomGenerator.JumpableGenerator interface returns a stream of EnhancedRandomGenerator objects, and is thus safe to cast the objects of the stream to EnhancedRandomGenerator. However, you may find it more convenient to instead utilize the ejumps() method, whose behavior is identical aside from the return type.

      Specified by:
      jumps in interface RandomGenerator.JumpableGenerator
      Returns:
      a stream of EnhancedRandomGenerator objects
    • jumps

      public final Stream<RandomGenerator> jumps(long streamSize)

      Gets a stream of EnhancedRandomGenerator objects, each wrapping an object of the same random number generator algorithm as this one. The random number generators in the stream are not also jumpable.

      The implementation of this method from the RandomGenerator.JumpableGenerator interface returns a stream of EnhancedRandomGenerator objects, and is thus safe to cast the objects of the stream to EnhancedRandomGenerator. However, you may find it more convenient to instead utilize the ejumps(long) method, whose behavior is identical aside from the return type.

      Specified by:
      jumps in interface RandomGenerator.JumpableGenerator
      Parameters:
      streamSize - the number of EnhancedRandomGenerator objects in the stream
      Returns:
      a stream of EnhancedRandomGenerator objects