23 #ifndef COUNTER_H_INCLUDED 24 #define COUNTER_H_INCLUDED 87 return ptr == other.ptr;
92 return ptr != other.ptr;
108 constexpr
static char separator =
'\'';
109 constexpr
static counter* end_value =
nullptr;
129 template<
class Iterator>
138 template<
class Iterable>
139 counter(Iterable
const& containor)
140 :
counter(containor.begin(), containor.end())
149 if (other.next != end_value)
150 next =
new counter(*other.next);
157 if (other.next != end_value)
158 next =
new counter(*other.next);
170 if (next != end_value)
176 return (next != end_value) ? (1 + next->size()) : 1;
189 const_iterator begin()
const 194 const_iterator end()
const 201 for (
auto& value : *
this)
205 template<
class Iterator>
206 void getCount(Iterator iter)
const 209 if (next != end_value)
210 next->getCount(++iter);
213 template<
class Iterator>
214 void setCount(Iterator iter)
217 if (next != end_value)
218 next->setCount(++iter);
221 void push_back(T max,
224 if (next != end_value)
225 (*next).push_back(max, value);
235 if (next != end_value)
248 T& operator[](
size_t pos)
252 return (*next)[pos-1];
255 T operator[](
size_t pos)
const 259 return (*next)[pos-1];
262 operator bool()
const 264 return (value != 0 or (next != end_value and
bool(*next)));
268 std::ostream& operator<<(std::ostream& out,
counter const& c)
271 if (c.next != counter::end_value)
272 out << counter::separator << *c.next;