Rosetta  2020.37
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions | Private Member Functions | Private Attributes | List of all members
numeric::random::ReservoirSampler< T > Class Template Reference

Simple container for keeping K random values. More...

#include <reservoir_sample.hh>

Public Member Functions

 ReservoirSampler (numeric::Size const wanted)
 
 ~ReservoirSampler ()=default
 
void add_value (T const &val)
 
numeric::Size n_vals () const
 
numeric::Size n_wanted () const
 
numeric::Size n_seen () const
 
utility::vector1< T > const & values () const
 

Private Member Functions

 ReservoirSampler ()
 

Private Attributes

utility::vector1< Tvalues_
 
numeric::Size n_seen_
 
numeric::Size const n_wanted_
 

Detailed Description

template<typename T>
class numeric::random::ReservoirSampler< T >

Simple container for keeping K random values.

Values are stochastically preserved so that the probability of any value existing is always 1 / N, where N is the number of values seen.

Constructor & Destructor Documentation

template<typename T >
numeric::random::ReservoirSampler< T >::ReservoirSampler ( numeric::Size const  wanted)
inline
template<typename T >
numeric::random::ReservoirSampler< T >::~ReservoirSampler ( )
default
template<typename T >
numeric::random::ReservoirSampler< T >::ReservoirSampler ( )
private

Member Function Documentation

template<typename T >
void numeric::random::ReservoirSampler< T >::add_value ( T const &  val)
inline
template<typename T >
numeric::Size numeric::random::ReservoirSampler< T >::n_seen ( ) const
inline
template<typename T >
numeric::Size numeric::random::ReservoirSampler< T >::n_vals ( ) const
inline
template<typename T >
numeric::Size numeric::random::ReservoirSampler< T >::n_wanted ( ) const
inline
template<typename T >
utility::vector1< T > const& numeric::random::ReservoirSampler< T >::values ( ) const
inline

Member Data Documentation

template<typename T >
numeric::Size numeric::random::ReservoirSampler< T >::n_seen_
private
template<typename T >
numeric::Size const numeric::random::ReservoirSampler< T >::n_wanted_
private
template<typename T >
utility::vector1< T > numeric::random::ReservoirSampler< T >::values_
private

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