Class IncrementalUniformRandomSelector

Class Documentation

class IncrementalUniformRandomSelector

Select uniformly at random from a set of elements that is discovered incrementally. Every time you discover a new element, you tell the selector and it will tell if you should keep the new element or your old element. As more and more elements are discovered, it will be less and less likely that the new element is chosen in order to ensure that the selection is uniformly at random. The process can be reset when a new class of elements is found that shall be used instead.

Public Functions

inline IncrementalUniformRandomSelector()

Initialize the random select for one element.

inline bool addElement()

Add the next element.

Note that this must not be called for the first element.

Returns:

If the new element shall be accepted/kept.

inline void reset()

Reset the process to one element again.