AME
ame::Wrap< T > Class Template Reference

A number to wrap between 0~length. More...

#include <ame_Util.hpp>

Public Member Functions

 Wrap (T length)
 
void set (T n)
 Sets the current value to an arbitrary number. More...
 
get (T offset=0) const noexcept
 Get the current value or the number of the current value plus an offset. More...
 
void changeLength (T newLength) noexcept
 The number to automatically wrap in the range [0, length-1]. More...
 
getLength () const noexcept
 
operator++ () noexcept
 Prefix increment. More...
 
operator++ (int) noexcept
 Postfix increment. More...
 
operator+= (T add) noexcept
 += operator. More...
 

Detailed Description

template<signed_number T>
class ame::Wrap< T >

A number to wrap between 0~length.

Template Parameters
Tsigned number (int32_t, float etc...)

Constructor & Destructor Documentation

◆ Wrap()

template<signed_number T>
ame::Wrap< T >::Wrap ( length)
inlineexplicit
Parameters
lengthThe number to automatically wrap in the range [0, length-1].

Member Function Documentation

◆ changeLength()

template<signed_number T>
void ame::Wrap< T >::changeLength ( newLength)
inlinenoexcept

The number to automatically wrap in the range [0, length-1].

Parameters
newLength

◆ get()

template<signed_number T>
T ame::Wrap< T >::get ( offset = 0) const
inlinenoexcept

Get the current value or the number of the current value plus an offset.

Parameters
offset
Returns
int_fast32_t [0, length-1]

◆ operator++() [1/2]

template<signed_number T>
T ame::Wrap< T >::operator++ ( )
inlinenoexcept

Prefix increment.

Returns
[0, length-1]

◆ operator++() [2/2]

template<signed_number T>
T ame::Wrap< T >::operator++ ( int  )
inlinenoexcept

Postfix increment.

Returns
[0, length-1]

◆ operator+=()

template<signed_number T>
T ame::Wrap< T >::operator+= ( add)
inlinenoexcept

+= operator.

Add and return wrapped number.

Parameters
add
Returns
[0, length-1]

◆ set()

template<signed_number T>
void ame::Wrap< T >::set ( n)
inline

Sets the current value to an arbitrary number.

When n is not in the range of 0~length-1, the wrapped number is used as the current value.

Parameters
n

The documentation for this class was generated from the following file: