llvm::ReservoirSampler

Randomly selects an item by sampling into a set with an unknown number of elements, which may each be weighted to be more likely choices.

Synopsis

Declared in <llvm/FuzzMutate/Random.h>

template<
    typename T,
    typename GenT>
class ReservoirSampler;

Member Functions

NameDescription
ReservoirSampler [constructor]Construct a sampler that draws randomness from RandGen.
getSelection Return the currently selected item.
isEmpty Return true if no items have been sampled yet.
operator* Return the currently selected item.
sample sample overloads
totalWeight Return the total weight of all items sampled so far.
operator bool Return true if a selection has been made.

Non-Member Functions

NameDescription
makeSamplerCreate an empty reservoir sampler over values of type T.
makeSamplerCreate a reservoir sampler and sample all items in Items with unit weight.
makeSamplerCreate a reservoir sampler and sample a single weighted item.