ATLAS Offline Software
Loading...
Searching...
No Matches
KFromNItr.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
3*/
4
5#ifndef TRIGCOMPOSITEUTILS_KFROMNITR_H
6#define TRIGCOMPOSITEUTILS_KFROMNITR_H
7
8#include <iterator>
9#include <vector>
10
11namespace TrigCompositeUtils {
35 {
36 public:
38 using iterator_category = std::input_iterator_tag;
39 using value_type = std::vector<std::size_t>;
40 using reference = const value_type &;
41 using pointer = const value_type *;
42 using difference_type = std::ptrdiff_t;
43
45 KFromNItr() = default;
46
48 KFromNItr(std::size_t k, std::size_t N);
49
51 std::size_t size() const { return m_current.size(); }
52
54 void reset();
55
57 bool exhausted() const;
58
60 reference operator*() const;
61 pointer operator->() const;
62
65
68
70 bool operator==(const KFromNItr &other) const;
71 bool operator!=(const KFromNItr &other) const;
72
73 private:
75 std::size_t m_N{0};
77 std::vector<std::size_t> m_current;
78 }; //> end class KFromNItr
79} //> end namespace TrigCompositeUtils
80
81#endif //> !TRIGCOMPOSITEUTILS_KFROMNITR_H
Iterates over all combinations of k values chosen from a range n.
Definition KFromNItr.h:35
bool exhausted() const
True if this iterator is past the end.
Definition KFromNItr.cxx:24
bool operator==(const KFromNItr &other) const
Iterator comparison functions.
bool operator!=(const KFromNItr &other) const
const value_type & reference
Definition KFromNItr.h:40
reference operator*() const
Dereference.
Definition KFromNItr.cxx:29
std::ptrdiff_t difference_type
Definition KFromNItr.h:42
KFromNItr()=default
Default constructor creates a generic past-the-end iterator.
KFromNItr & operator++()
Pre-increment operator.
Definition KFromNItr.cxx:43
std::size_t size() const
The size of each combination (k)
Definition KFromNItr.h:51
std::vector< std::size_t > value_type
Definition KFromNItr.h:39
std::input_iterator_tag iterator_category
Iterator traits.
Definition KFromNItr.h:38
void reset()
Reset the iterator to its start position.
Definition KFromNItr.cxx:18
std::vector< std::size_t > m_current
The current combination.
Definition KFromNItr.h:77
std::size_t m_N
The number of indices.
Definition KFromNItr.h:75
const value_type * pointer
Definition KFromNItr.h:41