ATLAS Offline Software
|
Iterates over all combinations of k values chosen from a range n. More...
#include <KFromNItr.h>
Public Types | |
using | iterator_category = std::input_iterator_tag |
Iterator traits. More... | |
using | value_type = std::vector< std::size_t > |
using | reference = const value_type & |
using | pointer = const value_type * |
using | difference_type = std::ptrdiff_t |
Public Member Functions | |
KFromNItr ()=default | |
Default constructor creates a generic past-the-end iterator. More... | |
KFromNItr (std::size_t k, std::size_t N) | |
Construct the iterator choosing k from N. More... | |
std::size_t | size () const |
The size of each combination (k) More... | |
void | reset () |
Reset the iterator to its start position. More... | |
bool | exhausted () const |
True if this iterator is past the end. More... | |
reference | operator* () const |
Dereference. More... | |
pointer | operator-> () const |
KFromNItr & | operator++ () |
Pre-increment operator. More... | |
KFromNItr | operator++ (int) |
Post-increment operator. More... | |
bool | operator== (const KFromNItr &other) const |
Iterator comparison functions. More... | |
bool | operator!= (const KFromNItr &other) const |
Private Attributes | |
std::size_t | m_N {0} |
The number of indices. More... | |
std::vector< std::size_t > | m_current |
The current combination. More... | |
Iterates over all combinations of k values chosen from a range n.
Generates all distinct combinations of k distinct values less than N.
This is an input iterator as it's impossible to satisfy the multi-pass guarantee in the forward iterator category where the return value is generated on the fly. However, this still follows the forward iterator convention that all past-the-end iterators compare equal, and that a default constructed iterator counts as a past-the-end iterator.
Combinations are generated in ascending order, with the indices in ascending order. The highest index is always incremented first if possible. Therefore the combinations generated by an iterator constructed as KFromNItr(3, 4); would be (0, 1, 2) (0, 1, 3) (0, 2, 3) (1, 2, 3)
Definition at line 34 of file KFromNItr.h.
using TrigCompositeUtils::KFromNItr::difference_type = std::ptrdiff_t |
Definition at line 42 of file KFromNItr.h.
using TrigCompositeUtils::KFromNItr::iterator_category = std::input_iterator_tag |
Iterator traits.
Definition at line 38 of file KFromNItr.h.
Definition at line 41 of file KFromNItr.h.
Definition at line 40 of file KFromNItr.h.
using TrigCompositeUtils::KFromNItr::value_type = std::vector<std::size_t> |
Definition at line 39 of file KFromNItr.h.
|
default |
Default constructor creates a generic past-the-end iterator.
TrigCompositeUtils::KFromNItr::KFromNItr | ( | std::size_t | k, |
std::size_t | N | ||
) |
bool TrigCompositeUtils::KFromNItr::exhausted | ( | ) | const |
True if this iterator is past the end.
Definition at line 24 of file KFromNItr.cxx.
bool TrigCompositeUtils::KFromNItr::operator!= | ( | const KFromNItr & | other | ) | const |
Definition at line 109 of file KFromNItr.cxx.
KFromNItr::reference TrigCompositeUtils::KFromNItr::operator* | ( | ) | const |
Dereference.
Definition at line 29 of file KFromNItr.cxx.
KFromNItr & TrigCompositeUtils::KFromNItr::operator++ | ( | ) |
KFromNItr TrigCompositeUtils::KFromNItr::operator++ | ( | int | ) |
KFromNItr::pointer TrigCompositeUtils::KFromNItr::operator-> | ( | ) | const |
Definition at line 36 of file KFromNItr.cxx.
Iterator comparison functions.
Definition at line 100 of file KFromNItr.cxx.
void TrigCompositeUtils::KFromNItr::reset | ( | ) |
Reset the iterator to its start position.
Definition at line 18 of file KFromNItr.cxx.
|
inline |
|
private |
The current combination.
Definition at line 77 of file KFromNItr.h.
|
private |
The number of indices.
Definition at line 75 of file KFromNItr.h.