LLVM 19.0.0git
Public Member Functions | List of all members
llvm::ReservoirSampler< T, GenT > Class Template Reference

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. More...

#include "llvm/FuzzMutate/Random.h"

Public Member Functions

 ReservoirSampler (GenT &RandGen)
 
uint64_t totalWeight () const
 
bool isEmpty () const
 
const TgetSelection () const
 
 operator bool () const
 
const Toperator* () const
 
template<typename RangeT >
ReservoirSamplersample (RangeT &&Items)
 Sample each item in Items with unit weight.
 
ReservoirSamplersample (const T &Item, uint64_t Weight)
 Sample a single item with the given weight.
 

Detailed Description

template<typename T, typename GenT>
class llvm::ReservoirSampler< T, GenT >

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.

Definition at line 33 of file Random.h.

Constructor & Destructor Documentation

◆ ReservoirSampler()

template<typename T , typename GenT >
llvm::ReservoirSampler< T, GenT >::ReservoirSampler ( GenT &  RandGen)
inline

Definition at line 39 of file Random.h.

Member Function Documentation

◆ getSelection()

template<typename T , typename GenT >
const T & llvm::ReservoirSampler< T, GenT >::getSelection ( ) const
inline

◆ isEmpty()

template<typename T , typename GenT >
bool llvm::ReservoirSampler< T, GenT >::isEmpty ( ) const
inline

◆ operator bool()

template<typename T , typename GenT >
llvm::ReservoirSampler< T, GenT >::operator bool ( ) const
inlineexplicit

Definition at line 49 of file Random.h.

References llvm::ReservoirSampler< T, GenT >::isEmpty().

◆ operator*()

template<typename T , typename GenT >
const T & llvm::ReservoirSampler< T, GenT >::operator* ( ) const
inline

Definition at line 50 of file Random.h.

References llvm::ReservoirSampler< T, GenT >::getSelection().

◆ sample() [1/2]

template<typename T , typename GenT >
ReservoirSampler & llvm::ReservoirSampler< T, GenT >::sample ( const T Item,
uint64_t  Weight 
)
inline

Sample a single item with the given weight.

Definition at line 60 of file Random.h.

References Selection.

◆ sample() [2/2]

template<typename T , typename GenT >
template<typename RangeT >
ReservoirSampler & llvm::ReservoirSampler< T, GenT >::sample ( RangeT &&  Items)
inline

Sample each item in Items with unit weight.

Definition at line 53 of file Random.h.

References I, and llvm::ReservoirSampler< T, GenT >::sample().

Referenced by llvm::makeSampler(), and llvm::ReservoirSampler< T, GenT >::sample().

◆ totalWeight()

template<typename T , typename GenT >
uint64_t llvm::ReservoirSampler< T, GenT >::totalWeight ( ) const
inline

Definition at line 41 of file Random.h.


The documentation for this class was generated from the following file: