#include <src/vt/utils/adt/ranged_counter.h>
template<typename T>
RangedCounter struct
A counter that operates over a fixed range and always stays within the range without overflowing (wraps around).
Constructors, destructors, conversion operators
- RangedCounter(T in_lo, T in_hi)
- Create a new
RangedCounter
with inclusive bounds. - operator T() const
- Get the current value as a conversion.
Public functions
- auto get() const -> T
- Get the current value (always within the range)
- auto operator++() -> RangedCounter<T>&
- Pre-increment operator.
- auto operator++(int) -> RangedCounter<T>
- Post-increment operator.
- auto operator--() -> RangedCounter<T>&
- Pre-decrement operator.
- auto operator--(int) -> RangedCounter<T>
- Post-decrement operator.
- void increment()
- Increment the value, keeping it within the range; wraps around if
cur_
== hi_. - void decrement()
- Decrement the value, keeping it within the range; wraps around if
cur_
== lo_.
Function documentation
template<typename T>
vt:: util:: adt:: RangedCounter<T>:: RangedCounter(T in_lo,
T in_hi)
Create a new RangedCounter
with inclusive bounds.
Parameters | |
---|---|
in_lo in | the low bound |
in_hi in | the high bound |
template<typename T>
T vt:: util:: adt:: RangedCounter<T>:: get() const
Get the current value (always within the range)
Returns | the current value |
---|