T
- Type of items in the collection.public class CollectionSampler<T> extends Object
Collection
.Constructor and Description |
---|
CollectionSampler(UniformRandomProvider rng,
Collection<T> collection)
Creates a sampler.
|
public CollectionSampler(UniformRandomProvider rng, 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.IllegalArgumentException
- if collection.size() <= 0
.public T sample()
collection
.
Sampling is without replacement; but if the source collection contains identical objects, the sample may include repeats.
There is no guarantee that the concrete type of the returned collection is the same as the source collection.
Copyright © 2016 The Apache Software Foundation. All rights reserved.