rcolyer.net
RC Lib  Version 201607061602
Public Member Functions | List of all members
RC::LoopIndex Class Reference

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.
 
LoopIndexoperator= (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.
 
LoopIndexoperator++ ()
 Increment by one, looping within range.
 
LoopIndex operator++ (int)
 Postfix increment by one, looping within range.
 
LoopIndexoperator-- ()
 Decrement by one, looping within range.
 
LoopIndex operator-- (int)
 Postfix decrement by one, looping within range.
 
LoopIndexoperator+= (size_t offset)
 Increment by offset, looping within range, and handling negative offsets correctly.
 
LoopIndexoperator-= (size_t offset)
 Decrement by offset, looping within range, and handling negative offsets correctly.
 

Detailed Description

A size_t like integer class which automatically stays within its range.

Use this for circular buffers or anywhere modulo arithmetic is needed.


The documentation for this class was generated from the following file:
email address
— (c) 2015