23 #ifndef COM_DAFER45_TBTK_MULTI_COUNTER
24 #define COM_DAFER45_TBTK_MULTI_COUNTER
41 template<
typename DataType>
52 const std::vector<DataType> &begin,
53 const std::vector<DataType> &end,
54 const std::vector<DataType> &increment
69 const DataType
operator[](
unsigned int n)
const;
72 operator std::vector<DataType>()
const;
89 std::vector<DataType> begin;
92 std::vector<DataType> end;
95 std::vector<DataType> increment;
98 std::vector<DataType> counter;
101 template<
typename DataType>
103 const std::vector<DataType> &begin,
104 const std::vector<DataType> &end,
105 const std::vector<DataType> &increment
108 begin.size() == end.size(),
109 "MultiCounter::MultiCounter()",
110 "'begin' and 'end' must have the same number of elements.",
114 begin.size() == increment.size(),
115 "MultiCounter::MultiCounter()",
116 "'begin' and 'increment' must have the same number of"
123 this->increment = increment;
125 for(
unsigned int n = 0; n < begin.size(); n++){
127 this->begin[n] <= this->end[n],
128 "MultiCounter::MultiCounter()",
129 "Only forward iteration is supported, but entry '" << n
130 <<
"' in 'end' is smaller than entry '" << n <<
"' in"
136 this->increment[n] > 0,
137 "MultiCounter::MultiCounter()",
138 "Only positive increments are supported, but entry '"
139 << n <<
"' in 'increment' is '" << this->increment[n]
148 template<
typename DataType>
150 for(
int n = counter.size()-1; n > 0; n--){
151 counter[n] += increment[n];
152 if(counter[n] < end[n])
155 counter[n] = begin[n];
158 counter[0] += increment[0];
163 template<
typename DataType>
168 template<
typename DataType>
173 template<
typename DataType>
178 template<
typename DataType>
180 return counter[0] >= end[0];
183 template<
typename DataType>