Class CollectionSampler<T>

java.lang.Object
org.apache.commons.rng.sampling.CollectionSampler<T>
Type Parameters:
T - Type of items in the collection.
All Implemented Interfaces:
ObjectSampler<T>, SharedStateObjectSampler<T>, SharedStateSampler<SharedStateObjectSampler<T>>

public class CollectionSampler<T> extends Object implements SharedStateObjectSampler<T>
Sampling from a Collection.

Sampling uses UniformRandomProvider.nextInt(int).

Since:
1.0
  • Field Details

  • Constructor Details

    • CollectionSampler

      public CollectionSampler(UniformRandomProvider rng, Collection<T> collection)
      Creates a sampler.
      Parameters:
      rng - Generator of uniformly distributed random numbers.
      collection - Collection to be sampled. A (shallow) copy will be stored in the created instance.
      Throws:
      IllegalArgumentException - if collection is empty.
    • CollectionSampler

      private CollectionSampler(UniformRandomProvider rng, CollectionSampler<T> source)
      Parameters:
      rng - Generator of uniformly distributed random numbers.
      source - Source to copy.
  • Method Details