E - the element typepublic interface RandomSelector<E>
| Modifier and Type | Method and Description |
|---|---|
default E |
pick()
Randomly pick an element.
|
E |
pick(Random random)
Randomly pick an element.
|
default Stream<E> |
stream()
Returns an effectively unlimited stream of random elements from this selector.
|
Stream<E> |
stream(Random random)
Returns an effectively unlimited stream of random elements from this selector.
|
static <E> RandomSelector<E> |
uniform(Collection<E> elements)
Creates a uniform selector which picks elements randomly.
|
static <E extends Weighted> |
weighted(Collection<E> elements)
Creates a weighted selector which picks elements according to the value of their
Weighted.getWeight(). |
static <E> RandomSelector<E> |
weighted(Collection<E> elements,
Weigher<? super E> weigher)
Creates a weighted selector which picks elements using their weight,
according to the weigher function.
|
static <E> RandomSelector<E> uniform(Collection<E> elements)
E - the element typeelements - the elements to pick fromstatic <E extends Weighted> RandomSelector<E> weighted(Collection<E> elements)
Weighted.getWeight().E - the element typeelements - the elements to pick fromstatic <E> RandomSelector<E> weighted(Collection<E> elements, Weigher<? super E> weigher)
E - the element typeelements - the elements to pick fromE pick(Random random)
random - the random instance to use for selectiondefault E pick()
Stream<E> stream(Random random)
random - the random instance to use for selectionCopyright © 2022. All rights reserved.