Public namespace. More...
Namespaces | |
detail | |
Implementation details. | |
rand_gen | |
Random number wrapper functions. | |
Classes | |
class | bad_parameter_value |
Thrown when a TRSL component receives a parameter that has a forbidden value. More... | |
class | is_picked_systematic |
Functor to use with persistent_filter_iterator for systematic sampling of a range. More... | |
class | mp_weight_accessor |
Method Pointer weight accessor. More... | |
class | persistent_filter_iterator |
Adaptation of boost::filter_iterator to allow an element to be selected multiple times. More... | |
class | ppfilter_iterator |
Random permutation, persistent filter iterator. More... | |
class | reorder_iterator |
Provides an iterator over a permutation of a range. More... | |
class | runtime_error |
Exception for runtime errors in TRSL. More... | |
struct | weight_accessor |
Weight accessor that always returns 1. More... | |
Functions | |
template<class Iterator > | |
bool | is_first_pick (const Iterator &i) |
Return whether *i has been picked already. More... | |
template<class Predicate , class Iterator > | |
persistent_filter_iterator< Predicate, Iterator > | make_persistent_filter_iterator (Predicate f, Iterator x, Iterator end=Iterator()) |
template<class Predicate , class Iterator > | |
persistent_filter_iterator< Predicate, Iterator > | make_persistent_filter_iterator (typename boost::iterators::enable_if< boost::is_class< Predicate >, Iterator >::type x, Iterator end=Iterator()) |
template<class ElementIterator > | |
reorder_iterator< ElementIterator > | random_permutation_iterator (ElementIterator first, ElementIterator last, unsigned permutationSize) |
Constructs a reorder_iterator that will iterate through a random subset of size permutationSize of a random permutation of the population referenced by first and last . More... | |
template<class ElementIterator > | |
reorder_iterator< ElementIterator > | random_permutation_iterator (ElementIterator first, ElementIterator last) |
Constructs a reorder_iterator that will iterate through a random permutation of the population referenced by first and last . More... | |
template<class ElementIterator , class ElementComparator > | |
reorder_iterator< ElementIterator > | sort_iterator (ElementIterator first, ElementIterator last, ElementComparator comp, unsigned permutationSize) |
Constructs a reorder_iterator that will iterate through the first permutationSize elements of a sorted permutation of the population referenced by first and last . More... | |
template<class ElementIterator , class ElementComparator > | |
reorder_iterator< ElementIterator > | sort_iterator (ElementIterator first, ElementIterator last, ElementComparator comp) |
Constructs a reorder_iterator that will iterate through a sorted permutation of the population referenced by first and last . More... | |
template<class ElementIterator > | |
reorder_iterator< ElementIterator > | sort_iterator (ElementIterator first, ElementIterator last) |
Constructs a reorder_iterator that will iterate through a sorted permutation of the population referenced by first and last . More... | |
Public namespace.
bool trsl::is_first_pick | ( | const Iterator & | i | ) |
Return whether *i
has been picked already.
This function calls i.predicate().is_first_pick(*i)
.
When sampling from a population, elements with a large weight may be selected several times. This function checks if the element pointed by i
has been selected already, e.g. at (i-1)
.
Iterator | Will typically be trsl::pp_filter_iterator or trsl::persitent_filter_iterator. |
i | Instance of pp_filter_iterator or persitent_filter_iterator. Should not be the end. |
Definition at line 321 of file is_picked_systematic.hpp.
reorder_iterator<ElementIterator> trsl::random_permutation_iterator | ( | ElementIterator | first, |
ElementIterator | last | ||
) |
Constructs a reorder_iterator that will iterate through a random permutation of the population referenced by first
and last
.
Performing a random permutation requires a series of random integers, these are provided by rand_gen::uniform_int; see Random Number Generators for further details.
ElementIterator
should model Random Access Iterator.
Creating such a reorder_iterator and iterating through it is generally much faster than re-ordering the population itself (or a copy thereof), especially when elements are large, have a complex copy-constructor, or a tall class hierarchy.
Definition at line 103 of file random_permutation_iterator.hpp.
References random_permutation_iterator().
reorder_iterator<ElementIterator> trsl::random_permutation_iterator | ( | ElementIterator | first, |
ElementIterator | last, | ||
unsigned | permutationSize | ||
) |
Constructs a reorder_iterator that will iterate through a random subset of size permutationSize
of a random permutation of the population referenced by first
and last
.
The permutationSize
should be smaller or equal to the size of the population. If it is not the case, a bad_parameter_value is thrown.
Performing a random permutation requires a series of random integers, these are provided by rand_gen::uniform_int; see Random Number Generators for further details.
ElementIterator
should model Random Access Iterator.
Creating such a reorder_iterator and iterating through it is generally much faster than re-ordering the population itself (or a copy thereof), especially when elements are large, have a complex copy-constructor, or a tall class hierarchy.
Definition at line 40 of file random_permutation_iterator.hpp.
References trsl::rand_gen::uniform_int().
Referenced by trsl::ppfilter_iterator< Predicate, ElementIterator >::ppfilter_iterator(), and random_permutation_iterator().
reorder_iterator<ElementIterator> trsl::sort_iterator | ( | ElementIterator | first, |
ElementIterator | last | ||
) |
Constructs a reorder_iterator that will iterate through a sorted permutation of the population referenced by first
and last
.
The population is sorted using std::less<>()
, i.e. in ascending order.
ElementIterator
should model Random Access Iterator.
Creating such a reorder_iterator and iterating through it is generally much faster than re-ordering the population itself (or a copy thereof), especially when elements are large, have a complex copy-constructor, or a tall class hierarchy.
Definition at line 180 of file sort_iterator.hpp.
References sort_iterator().
reorder_iterator<ElementIterator> trsl::sort_iterator | ( | ElementIterator | first, |
ElementIterator | last, | ||
ElementComparator | comp | ||
) |
Constructs a reorder_iterator that will iterate through a sorted permutation of the population referenced by first
and last
.
A comparator is provided through comp
. Comparator
has to model Strict Weak Ordering. In particular std::less<ElementType>()
and std::greater<ElementType>()
can work, whereas std::less_equal<ElementType>()
and std::greater_equal<ElementType>()
will not.
ElementIterator
should model Random Access Iterator.
Creating such a reorder_iterator and iterating through it is generally much faster than re-ordering the population itself (or a copy thereof), especially when elements are large, have a complex copy-constructor, or a tall class hierarchy.
Definition at line 153 of file sort_iterator.hpp.
References sort_iterator().
reorder_iterator<ElementIterator> trsl::sort_iterator | ( | ElementIterator | first, |
ElementIterator | last, | ||
ElementComparator | comp, | ||
unsigned | permutationSize | ||
) |
Constructs a reorder_iterator that will iterate through the first permutationSize
elements of a sorted permutation of the population referenced by first
and last
.
The permutationSize
should be smaller or equal to the size of the population. If it is not the case, a bad_parameter_value is thrown.
A comparator is provided through comp
. Comparator
has to model Strict Weak Ordering. In particular std::less<ElementType>()
and std::greater<ElementType>()
will work, whereas std::less_equal<ElementType>()
and std::greater_equal<ElementType>()
will not.
ElementIterator
should model Random Access Iterator.
Creating such a reorder_iterator and iterating through it is generally much faster than re-ordering the population itself (or a copy thereof), especially when elements are large, have a complex copy-constructor, or a tall class hierarchy.
Definition at line 76 of file sort_iterator.hpp.
Referenced by sort_iterator().