![]() |
![]() |
#include <CombinatoricGenerator.h>
Classes | |
class | IndexInSet |
class | ValueAccessor |
Public Types | |
typedef boost::filter_iterator < IndexInSet, index_iter > | ComboIter |
typedef boost::transform_iterator < ValueAccessor, ComboIter > | ValueIter |
Public Member Functions | |
Combinatoric (const value_iter &begin, const indices_collection &indices, indices_collection combo, bool done) | |
const indices_set & | combo () const |
Return the set of selected indices. | |
ValueIter | combo_begin () const |
The first element in the selected subset. | |
ValueIter | combo_end () const |
One past the last element in the selected subset. | |
bool | done () const |
Combinatoric< T > | next () const |
Build the next cominatoric subset after the current one. | |
bool | operator== (const Combinatoric< T > &rhs) const |
Comparison to another combination. | |
ValueIter | remainder_begin () const |
One past the last element in the non-selected subset. | |
ValueIter | remainder_end () const |
The first element in the non-selected subset. | |
Private Types | |
typedef indices_collection::const_iterator | index_iter |
typedef size_t | index_type |
typedef std::vector< index_type > | indices_collection |
typedef std::set< index_type > | indices_set |
typedef T::const_iterator | value_iter |
typedef T::value_type | value_type |
Private Attributes | |
value_iter | begin_ |
indices_collection | combo_ |
indices_set | comboSet_ |
bool | done_ |
IndexInSet | inChoice_ |
indices_collection | indices_ |
IndexInSet | notInChoice_ |
ValueAccessor | valueAccessor_ |
Definition at line 50 of file CombinatoricGenerator.h.
typedef boost::filter_iterator<IndexInSet, index_iter> reco::tau::Combinatoric< T >::ComboIter |
Definition at line 110 of file CombinatoricGenerator.h.
typedef indices_collection::const_iterator reco::tau::Combinatoric< T >::index_iter [private] |
Definition at line 69 of file CombinatoricGenerator.h.
typedef size_t reco::tau::Combinatoric< T >::index_type [private] |
Definition at line 67 of file CombinatoricGenerator.h.
typedef std::vector<index_type> reco::tau::Combinatoric< T >::indices_collection [private] |
Definition at line 68 of file CombinatoricGenerator.h.
typedef std::set<index_type> reco::tau::Combinatoric< T >::indices_set [private] |
Definition at line 70 of file CombinatoricGenerator.h.
typedef T::const_iterator reco::tau::Combinatoric< T >::value_iter [private] |
Definition at line 65 of file CombinatoricGenerator.h.
typedef T::value_type reco::tau::Combinatoric< T >::value_type [private] |
Definition at line 66 of file CombinatoricGenerator.h.
typedef boost::transform_iterator<ValueAccessor, ComboIter> reco::tau::Combinatoric< T >::ValueIter |
Definition at line 111 of file CombinatoricGenerator.h.
reco::tau::Combinatoric< T >::Combinatoric | ( | const value_iter & | begin, |
const indices_collection & | indices, | ||
indices_collection | combo, | ||
bool | done | ||
) | [inline] |
const indices_set& reco::tau::Combinatoric< T >::combo | ( | ) | const [inline] |
Return the set of selected indices.
Definition at line 187 of file CombinatoricGenerator.h.
References reco::tau::Combinatoric< T >::comboSet_.
Referenced by reco::tau::Combinatoric< T >::operator==().
{ return comboSet_; }
ValueIter reco::tau::Combinatoric< T >::combo_begin | ( | ) | const [inline] |
The first element in the selected subset.
Definition at line 114 of file CombinatoricGenerator.h.
References reco::tau::Combinatoric< T >::inChoice_, reco::tau::Combinatoric< T >::indices_, and reco::tau::Combinatoric< T >::valueAccessor_.
ValueIter reco::tau::Combinatoric< T >::combo_end | ( | ) | const [inline] |
One past the last element in the selected subset.
Definition at line 116 of file CombinatoricGenerator.h.
References reco::tau::Combinatoric< T >::inChoice_, reco::tau::Combinatoric< T >::indices_, and reco::tau::Combinatoric< T >::valueAccessor_.
bool reco::tau::Combinatoric< T >::done | ( | ) | const [inline] |
Definition at line 184 of file CombinatoricGenerator.h.
References reco::tau::Combinatoric< T >::done_.
Referenced by reco::tau::Combinatoric< T >::next(), and reco::tau::Combinatoric< T >::operator==().
{ return done_; }
Combinatoric<T> reco::tau::Combinatoric< T >::next | ( | void | ) | const [inline] |
Build the next cominatoric subset after the current one.
Definition at line 124 of file CombinatoricGenerator.h.
References reco::tau::Combinatoric< T >::begin_, reco::tau::Combinatoric< T >::combo_, reco::tau::Combinatoric< T >::done(), reco::tau::Combinatoric< T >::indices_, and pos.
{ //std::cout << "building next: " << std::endl; //std::cout << "current " << std::endl; //std::copy(combo_.begin(), combo_.end(), std::ostream_iterator<int>(std::cout, " ")); //std::cout << std::endl; indices_collection newCombo(combo_); // Find the first value that can be updated (starting from the back // max value for index is (nElements-1) - (distance from end) // Examples: // 189 -> 289 (will be updated to 234) // 179 -> 189 // 123 -> 124 size_t distanceFromEnd = 0; size_t nElements = indices_.size(); indices_collection::reverse_iterator pos = newCombo.rbegin(); for(; pos != newCombo.rend(); ++pos, ++distanceFromEnd) { // Check if we can update this element to the next value (without overflow) // If so, increment it it, then quit if( *pos < (nElements - 1 - distanceFromEnd) ) { (*pos)++; break; } else { // Set to 'unset value' - we need to update it! (*pos) = nElements; } } //std::cout << "after update " << std::endl; //std::copy(newCombo.begin(), newCombo.end(), std::ostream_iterator<int>(std::cout, " ")); //std::cout << std::endl; // Everything after pos needs to be updated. i.e. 159 -> 167 index_type next_pos_value = (*pos)+1; // forward_pos points to the element *after* pos indices_collection::iterator forward_pos = pos.base(); // Only do the updates if we have not reached all the way to the beginning! // this indicates we are at the end of the iteration. We return a combo // with all values at nElements to flag that we are at the end bool done = true; if (forward_pos != newCombo.begin()) { done = false; for (; forward_pos != newCombo.end(); ++forward_pos, ++next_pos_value) { *forward_pos = next_pos_value; } } //std::cout << "final " << std::endl; //std::copy(newCombo.begin(), newCombo.end(), std::ostream_iterator<int>(std::cout, " ")); //std::cout << std::endl; //return std::auto_ptr<Combinatoric<T> >(new Combinatoric<T>(begin_, indices_, newCombo)); return Combinatoric<T>(begin_, indices_, newCombo, done); }
bool reco::tau::Combinatoric< T >::operator== | ( | const Combinatoric< T > & | rhs | ) | const [inline] |
Comparison to another combination.
Definition at line 190 of file CombinatoricGenerator.h.
References reco::tau::Combinatoric< T >::combo(), and reco::tau::Combinatoric< T >::done().
ValueIter reco::tau::Combinatoric< T >::remainder_begin | ( | ) | const [inline] |
One past the last element in the non-selected subset.
Definition at line 121 of file CombinatoricGenerator.h.
References reco::tau::Combinatoric< T >::indices_, reco::tau::Combinatoric< T >::notInChoice_, and reco::tau::Combinatoric< T >::valueAccessor_.
{ return ValueIter(ComboIter(notInChoice_, indices_.begin(), indices_.end()), valueAccessor_); }
ValueIter reco::tau::Combinatoric< T >::remainder_end | ( | ) | const [inline] |
The first element in the non-selected subset.
Definition at line 119 of file CombinatoricGenerator.h.
References reco::tau::Combinatoric< T >::indices_, reco::tau::Combinatoric< T >::notInChoice_, and reco::tau::Combinatoric< T >::valueAccessor_.
{ return ValueIter(ComboIter(notInChoice_, indices_.end(), indices_.end()), valueAccessor_); }
value_iter reco::tau::Combinatoric< T >::begin_ [private] |
Definition at line 198 of file CombinatoricGenerator.h.
Referenced by reco::tau::Combinatoric< T >::next().
indices_collection reco::tau::Combinatoric< T >::combo_ [private] |
Definition at line 199 of file CombinatoricGenerator.h.
Referenced by reco::tau::Combinatoric< T >::next().
indices_set reco::tau::Combinatoric< T >::comboSet_ [private] |
Definition at line 200 of file CombinatoricGenerator.h.
Referenced by reco::tau::Combinatoric< T >::combo().
bool reco::tau::Combinatoric< T >::done_ [private] |
Definition at line 202 of file CombinatoricGenerator.h.
Referenced by reco::tau::Combinatoric< T >::done().
IndexInSet reco::tau::Combinatoric< T >::inChoice_ [private] |
Definition at line 204 of file CombinatoricGenerator.h.
Referenced by reco::tau::Combinatoric< T >::combo_begin(), and reco::tau::Combinatoric< T >::combo_end().
indices_collection reco::tau::Combinatoric< T >::indices_ [private] |
IndexInSet reco::tau::Combinatoric< T >::notInChoice_ [private] |
Definition at line 205 of file CombinatoricGenerator.h.
Referenced by reco::tau::Combinatoric< T >::remainder_begin(), and reco::tau::Combinatoric< T >::remainder_end().
ValueAccessor reco::tau::Combinatoric< T >::valueAccessor_ [private] |
Definition at line 203 of file CombinatoricGenerator.h.
Referenced by reco::tau::Combinatoric< T >::combo_begin(), reco::tau::Combinatoric< T >::combo_end(), reco::tau::Combinatoric< T >::remainder_begin(), and reco::tau::Combinatoric< T >::remainder_end().