Class RandomStreams.SeededObjectSpliterator<T>

java.lang.Object
org.apache.commons.rng.core.util.RandomStreams.SeededObjectSpliterator<T>
Type Parameters:
T - the object type
All Implemented Interfaces:
Spliterator<T>
Enclosing class:
RandomStreams

private static final class RandomStreams.SeededObjectSpliterator<T> extends Object implements Spliterator<T>
Spliterator for streams of a given object type that can be created from a seed and source of randomness. The source of randomness is splittable allowing parallel stream support.

The seed is mixed with the stream position to ensure each object is created using a unique seed value. As the position increases the seed is left shifted until there is no bit overlap between the seed and the position, i.e the right-most 1-bit of the seed is larger than the left-most 1-bit of the position. s

  • Field Details

    • NULL_ACTION

      private static final String NULL_ACTION
      Message when the consumer action is null.
      See Also:
    • position

      private long position
      The current position in the range.
    • end

      private final long end
      The upper limit of the range.
    • seed

      private long seed
      Seed used to initialise the new instances. The least significant 1-bit of the seed must be above the most significant bit of the position. This is maintained by left shift when the position is updated.
    • source

      private final SplittableUniformRandomProvider source
      Source of randomness used to initialise the new instances.
    • factory

      private final RandomStreams.SeededObjectFactory<T> factory
      Factory to create new instances.
  • Constructor Details

    • SeededObjectSpliterator

      SeededObjectSpliterator(long start, long end, SplittableUniformRandomProvider source, RandomStreams.SeededObjectFactory<T> factory, long seed)
      Parameters:
      start - Start position of the stream (inclusive).
      end - Upper limit of the stream (exclusive).
      source - Source of randomness used to initialise the new instances.
      factory - Factory to create new instances.
      seed - Seed used to initialise the instances. The least significant 1-bit of the seed must be above the most significant bit of the start position.
  • Method Details