LArSoft
v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
|
An iterator dereferencing to a counter value. More...
#include "counter.h"
Public Types | |
Traits and data types | |
using | iterator_type = count_iterator< T > |
Type of this iterator. More... | |
using | difference_type = std::ptrdiff_t |
Type of this iterator. More... | |
using | value_type = T |
Type of index returned by this iterator. More... | |
using | reference = T const & |
Type returned by dereference operator. More... | |
using | pointer = T * |
Type of this iterator. More... | |
using | iterator_category = std::bidirectional_iterator_tag |
Type of this iterator. More... | |
Public Member Functions | |
Construction | |
count_iterator ()=default | |
Initializes the iterator. More... | |
count_iterator (value_type count) | |
Initializes the iterator with the specified loop count. More... | |
Data access | |
reference | operator* () const |
Returns the current loop count. More... | |
Modification | |
iterator_type & | operator++ () |
Increments the loop count of this iterator, which is then returned. More... | |
iterator_type | operator++ (int) const |
iterator_type & | operator-- () |
Decrements the loop count of this iterator, which is then returned. More... | |
iterator_type | operator-- (int) const |
Comparisons | |
template<typename U > | |
bool | operator== (count_iterator< U > const &other) const |
Iterators are equal if their loop counts compare equal. More... | |
template<typename U > | |
bool | operator!= (count_iterator< U > const &other) const |
Iterators are equal if their loop counts compare different. More... | |
Private Attributes | |
value_type | fCount {} |
Internal counter. More... | |
An iterator dereferencing to a counter value.
T | the type of counter returned on dereferenciation |
util::counter()
This iterator returns on dereferencing the net count of how many times it has been incremented. So for example:
this infinite loop will push the value 0
into data
on the first iteration, 1
on the second and so forth, until at the eleventh iteration, just before it can push 10
, the loop is forcibly broken leaving 10 elements in data
.
The iterator can be made to start from an index n
different than 0
, in which case it behaves like it had already been incremented n
times. End iterators can be build in that way too; see also util::counter()
.
using util::count_iterator< T >::difference_type = std::ptrdiff_t |
using util::count_iterator< T >::iterator_category = std::bidirectional_iterator_tag |
using util::count_iterator< T >::iterator_type = count_iterator<T> |
using util::count_iterator< T >::pointer = T* |
using util::count_iterator< T >::reference = T const& |
using util::count_iterator< T >::value_type = T |
|
default |
Initializes the iterator.
The initial loop count is the default-constructed value of the counter type, which is usually some variation on the concept of 0
.
Referenced by util::counter(), and util::infinite_counter().
|
inline |
|
inline |
Iterators are equal if their loop counts compare different.
Definition at line 153 of file counter.h.
References util::count_iterator< T >::fCount.
|
inline |
Returns the current loop count.
Definition at line 96 of file counter.h.
References util::count_iterator< T >::fCount.
|
inline |
Increments the loop count of this iterator, which is then returned.
Definition at line 106 of file counter.h.
References util::count_iterator< T >::fCount.
Referenced by util::count_iterator< T >::operator++().
|
inline |
Increments the loop count of this iterator, returning a copy with the value before the increment.
Definition at line 114 of file counter.h.
References util::count_iterator< T >::operator++().
|
inline |
Decrements the loop count of this iterator, which is then returned.
Definition at line 122 of file counter.h.
References util::count_iterator< T >::fCount.
Referenced by util::count_iterator< T >::operator--().
|
inline |
Decrements the loop count of this iterator, returning a copy with the value before the decrement.
Definition at line 130 of file counter.h.
References util::count_iterator< T >::operator--().
|
inline |
Iterators are equal if their loop counts compare equal.
Definition at line 146 of file counter.h.
References util::count_iterator< T >::fCount.
|
private |
Internal counter.
Definition at line 162 of file counter.h.
Referenced by util::count_iterator< T >::operator!=(), util::count_iterator< T >::operator*(), util::count_iterator< T >::operator++(), util::count_iterator< T >::operator--(), and util::count_iterator< T >::operator==().