|
|
Go to the documentation of this file. 1 #ifndef RecoTauTag_RecoTau_CombinatoricGenerator_h
2 #define RecoTauTag_RecoTau_CombinatoricGenerator_h
4 #include <boost/iterator/iterator_facade.hpp>
5 #include <boost/iterator/filter_iterator.hpp>
6 #include <boost/iterator/transform_iterator.hpp>
69 typedef typename indices_collection::const_iterator
index_iter;
110 typedef typename boost::filter_iterator<IndexInSet, index_iter>
ComboIter;
111 typedef typename boost::transform_iterator<ValueAccessor, ComboIter>
ValueIter;
146 size_t distanceFromEnd = 0;
148 indices_collection::reverse_iterator
pos = newCombo.rbegin();
149 for (;
pos != newCombo.rend(); ++
pos, ++distanceFromEnd) {
152 if (*
pos < (nElements - 1 - distanceFromEnd)) {
166 indices_collection::iterator forward_pos =
pos.base();
171 if (forward_pos != newCombo.begin()) {
176 for (; forward_pos != newCombo.end(); ++forward_pos, ++next_pos_value) {
177 *forward_pos = next_pos_value;
213 template <
typename T>
215 :
public boost::iterator_facade<CombinatoricIterator<T>, const Combinatoric<T>, boost::forward_traversal_tag> {
233 template <
typename T>
264 if (
choose <= totalElements) {
266 for (
size_t i = 0;
i < totalElements; ++
i) {
273 finalCombo[
i] = totalElements;
std::unique_ptr< CombinatoricIterator< T > > CombIterPtr
T::const_iterator value_iter
IndexInSet(const indices_set &combo, bool negate)
T::const_iterator value_iter
const indices_set & combo() const
Return the set of selected indices.
boost::filter_iterator< IndexInSet, index_iter > ComboIter
std::set< index_type > indices_set
indices_collection::iterator index_iter
CombinatoricGenerator(const value_iter &begin, const value_iter &end, size_t choose)
ValueAccessor valueAccessor_
ValueIter remainder_end() const
The first element in the non-selected subset.
Combinatoric< T > value_type
indices_collection::const_iterator index_iter
std::set< index_type > indices_set
std::vector< index_type > indices_collection
CombinatoricIterator< T > iterator
ValueIter combo_begin() const
The first element in the selected subset.
bool equal(CombinatoricIterator const &other) const
ValueAccessor(const value_iter &begin)
const Combinatoric< T > & dereference() const
std::vector< index_type > indices_collection
CombinatoricIterator< T > end()
bool operator()(const index_type &index) const
friend class boost::iterator_core_access
Container::value_type value_type
indices_collection indices_
ValueIter combo_end() const
One past the last element in the selected subset.
indices_collection combo_
Combinatoric(const value_iter &begin, const indices_collection &indices, const indices_collection &combo, bool done)
iterator::value_type::ValueIter combo_iterator
const value_type & operator()(index_type const &index) const
Combinatoric< T > next() const
Build the next cominatoric subset after the current one.
CombinatoricIterator(const Combinatoric< T > &c)
boost::transform_iterator< ValueAccessor, ComboIter > ValueIter
CombinatoricIterator< T > begin()
ValueIter remainder_begin() const
One past the last element in the non-selected subset.
bool operator==(const Combinatoric< T > &rhs) const
Comparison to another combination.