T
- Type of items in the collection.public class CollectionSampler<T> extends java.lang.Object
Collection
.Constructor | Description |
---|---|
CollectionSampler(org.apache.commons.rng.UniformRandomProvider rng,
java.util.Collection<T> collection) |
Creates a sampler.
|
Modifier and Type | Method | Description |
---|---|---|
T |
sample() |
Picks one of the items from the
collection passed to the constructor . |
public CollectionSampler(org.apache.commons.rng.UniformRandomProvider rng, java.util.Collection<T> collection)
rng
- Generator of uniformly distributed random numbers.collection
- Collection to be sampled.
A (shallow) copy will be stored in the created instance.java.lang.IllegalArgumentException
- if collection
is empty.public T sample()
collection passed to the constructor
.Copyright © 2016–2018 The Apache Software Foundation. All rights reserved.