A size_t like integer class which automatically stays within its range. More...
#include <RCBits.h>
Public Member Functions | |
LoopIndex (size_t range) | |
Defines the range of of the object. The index is always less than this. | |
size_t | Range () const |
Returns the set range. | |
void | SetRange (size_t new_range) |
Sets a new range. | |
LoopIndex & | operator= (size_t new_index) |
Assigns a new index value, forcing it in the range. Signed indices are handled properly. | |
operator size_t () const | |
Implicitly returns the size_t index. | |
LoopIndex & | operator++ () |
Increment by one, looping within range. | |
LoopIndex | operator++ (int) |
Postfix increment by one, looping within range. | |
LoopIndex & | operator-- () |
Decrement by one, looping within range. | |
LoopIndex | operator-- (int) |
Postfix decrement by one, looping within range. | |
LoopIndex & | operator+= (size_t offset) |
Increment by offset, looping within range, and handling negative offsets correctly. | |
LoopIndex & | operator-= (size_t offset) |
Decrement by offset, looping within range, and handling negative offsets correctly. | |
A size_t like integer class which automatically stays within its range.
Use this for circular buffers or anywhere modulo arithmetic is needed.