java.lang.Object
org.jgrapht.util.ElementsSequenceGenerator<T>
- Type Parameters:
T
- element type
Generates elements from the input collection in random order.
An element can be generated only once. After all elements have been generated, this generator halts. At every step, an element is generated uniformly at random, which means that every element has an equal probability to be generated. This implementation is based on the Fisher-Yates algorithm. The generator is unbiased meaning the every permutation is equally likely.
- Author:
- Timofey Chudakov
-
Constructor Summary
ConstructorDescriptionElementsSequenceGenerator
(Collection<T> elements) Constructs a newElementsSequenceGenerator
.ElementsSequenceGenerator
(Collection<T> elements, long seed) Constructs a newElementsSequenceGenerator
using the specifiedseed
.ElementsSequenceGenerator
(Collection<T> elements, Random rng) Constructs a newElementsSequenceGenerator
using the specified random number generatorrng
. -
Method Summary
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface java.lang.Iterable
forEach, spliterator
Methods inherited from interface java.util.Iterator
forEachRemaining, remove
-
Constructor Details
-
ElementsSequenceGenerator
Constructs a newElementsSequenceGenerator
.- Parameters:
elements
- a collection of elements to generate elements from.
-
ElementsSequenceGenerator
Constructs a newElementsSequenceGenerator
using the specifiedseed
. Two different generators with the same seed will produce identical sequences given that the same collection of elements is provided.- Parameters:
elements
- a collection of elements to generate elements from.seed
- a seed for the random number generator
-
ElementsSequenceGenerator
Constructs a newElementsSequenceGenerator
using the specified random number generatorrng
. Two different generators will produce identical sequences from a collection of elements given that the random number generator produces the same sequence of numbers.- Parameters:
elements
- a collection of elements to generate elements from.rng
- a random number generator
-
-
Method Details