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> 47 namespace reco {
namespace tau {
69 typedef typename indices_collection::const_iterator
index_iter;
102 const indices_collection&
combo,
bool done):
110 typedef typename boost::filter_iterator<IndexInSet, index_iter>
ComboIter;
111 typedef typename boost::transform_iterator<ValueAccessor, ComboIter>
ValueIter;
131 indices_collection newCombo(
combo_);
139 size_t distanceFromEnd = 0;
141 indices_collection::reverse_iterator
pos = newCombo.rbegin();
142 for(; pos != newCombo.rend(); ++pos, ++distanceFromEnd)
146 if( *pos < (nElements - 1 - distanceFromEnd) )
161 indices_collection::iterator forward_pos = pos.base();
166 if (forward_pos != newCombo.begin()) {
168 index_type next_pos_value = (*pos)+1;
171 for (; forward_pos != newCombo.end(); ++forward_pos, ++next_pos_value) {
172 *forward_pos = next_pos_value;
211 CombinatoricIterator<T>,
212 const Combinatoric<T>,
213 boost::forward_traversal_tag>
221 friend class boost::iterator_core_access;
224 return this->node_ == other.
node_;
228 node_ = node_.next();
267 indices_collection initialCombo(choose);
268 indices_collection finalCombo(choose);
270 size_t totalElements = end-
begin;
272 if (choose <= totalElements) {
273 indices_collection allIndices(totalElements);
274 for(
size_t i=0;
i < totalElements; ++
i)
283 finalCombo[
i] = totalElements;
287 begin, allIndices, initialCombo,
false)));
290 begin, allIndices, finalCombo,
true)));
CombinatoricIterator(const Combinatoric< T > &c)
CombinatoricIterator< T > end()
indices_collection combo_
Combinatoric< T > value_type
std::vector< index_type > indices_collection
indices_collection::const_iterator index_iter
const Combinatoric< T > & dereference() const
T::const_iterator value_iter
ValueIter combo_end() const
One past the last element in the selected subset.
Container::value_type value_type
ValueAccessor(const value_iter &begin)
CombinatoricGenerator(const value_iter &begin, const value_iter &end, size_t choose)
Combinatoric(const value_iter &begin, const indices_collection &indices, const indices_collection &combo, bool done)
bool equal(CombinatoricIterator const &other) const
indices_collection indices_
boost::filter_iterator< IndexInSet, index_iter > ComboIter
T::const_iterator value_iter
ValueAccessor valueAccessor_
ValueIter remainder_begin() const
One past the last element in the non-selected subset.
bool operator()(const index_type &index) const
ValueIter remainder_end() const
The first element in the non-selected subset.
ValueIter combo_begin() const
The first element in the selected subset.
Combinatoric< T > next() const
Build the next cominatoric subset after the current one.
const indices_set & combo() const
Return the set of selected indices.
CombinatoricIterator< T > iterator
indices_collection::iterator index_iter
std::vector< index_type > indices_collection
std::unique_ptr< CombinatoricIterator< T > > CombIterPtr
boost::transform_iterator< ValueAccessor, ComboIter > ValueIter
bool operator==(const Combinatoric< T > &rhs) const
Comparison to another combination.
std::set< index_type > indices_set
const value_type & operator()(index_type const &index) const
iterator::value_type::ValueIter combo_iterator
std::set< index_type > indices_set
CombinatoricIterator< T > begin()
IndexInSet(const indices_set &combo, bool negate)