You.i Engine
CYIRange< Type > Class Template Reference

Detailed Description

template<typename Type>
class CYIRange< Type >

A general-purpose range object, that simply represents any linear range with a start and end point.

Note that when checking whether values fall within the range, the start value is considered to be inclusive, and the end of the range exclusive.

The templated parameter is expected to be a primitive type, be it an integer or a floating point type.

Warning
Though allowed, negative values will behave unexpectedly with unsigned integral ranges.

#include <utility/YiRange.h>

Public Member Functions

 CYIRange ()
 
 CYIRange (Type lhs, Type rhs)
 
 CYIRange (const CYIRange< Type > &other)
 
Type GetStart () const
 
Type GetEnd () const
 
Type GetLength () const
 
bool IsEmpty () const
 
bool IsNotEmpty () const
 
void SetStart (Type newStart)
 
void SetEnd (Type newEnd)
 
void SetLength (Type newLength)
 
CYIRange< Type > WithStart (Type newStart) const
 
CYIRange< Type > WithEnd (Type newEnd) const
 
CYIRange< Type > WithLength (Type newLength) const
 
CYIRange< Type > Expanded (Type amount) const
 
CYIRange< Type > Shifted (Type delta) const
 
bool Contains (Type position) const
 
CYIRange< Type > & operator= (const CYIRange< Type > &other)
 
CYIRange< Type > operator+= (Type delta)
 
CYIRange< Type > operator-= (Type delta)
 
CYIRange< Type > operator+ (Type delta) const
 
CYIRange< Type > operator- (Type delta) const
 
bool operator== (const CYIRange< Type > &other) const
 
bool operator!= (const CYIRange< Type > &other) const
 

Static Public Member Functions

static CYIRange CreateEmptyRange (Type m_start)
 
static CYIRange CreateWithStartAndLength (Type startValue, Type length)
 

Constructor & Destructor Documentation

template<typename Type>
CYIRange< Type >::CYIRange ( )
inline

Constructs an empty range.

template<typename Type>
CYIRange< Type >::CYIRange ( Type  lhs,
Type  rhs 
)
inline

Constructs a range with given lhs and rhs values. The order doesn't matter.

template<typename Type>
CYIRange< Type >::CYIRange ( const CYIRange< Type > &  other)
inline

Constructs a copy of another range.

Member Function Documentation

template<typename Type>
bool CYIRange< Type >::Contains ( Type  position) const
inline

Returns true if the given position lies inside this range.

When making this comparison, the start value is considered to be inclusive, and the end of the range exclusive.

template<typename Type>
static CYIRange CYIRange< Type >::CreateEmptyRange ( Type  m_start)
inlinestatic

Returns a range with the specified start position and a length of zero.

template<typename Type>
static CYIRange CYIRange< Type >::CreateWithStartAndLength ( Type  startValue,
Type  length 
)
inlinestatic

Returns a range with a given start and length.

template<typename Type>
CYIRange<Type> CYIRange< Type >::Expanded ( Type  amount) const
inline

Returns a range which has its start moved down and its end moved up by the given amount.

template<typename Type>
Type CYIRange< Type >::GetEnd ( ) const
inline

Returns the end of the range.

template<typename Type>
Type CYIRange< Type >::GetLength ( ) const
inline

Returns the length of the range.

template<typename Type>
Type CYIRange< Type >::GetStart ( ) const
inline

Returns the start of the range.

template<typename Type>
bool CYIRange< Type >::IsEmpty ( ) const

Returns true if the range has a length of zero.

template<typename Type>
bool CYIRange< Type >::IsNotEmpty ( ) const
inline

Returns true if the range has a non-zero length.

template<typename Type>
bool CYIRange< Type >::operator!= ( const CYIRange< Type > &  other) const
inline
template<typename Type>
CYIRange<Type> CYIRange< Type >::operator+ ( Type  delta) const
inline

Returns a range that is equal to this one with an amount added to its start and end.

template<typename Type>
CYIRange<Type> CYIRange< Type >::operator+= ( Type  delta)
inline

Moves the range positively by the provided delta, or negatitvely if the delta is negative.

template<typename Type>
CYIRange<Type> CYIRange< Type >::operator- ( Type  delta) const
inline

Returns a range that is equal to this one with an amount subtracted to its start and end.

template<typename Type>
CYIRange<Type> CYIRange< Type >::operator-= ( Type  delta)
inline

Moves the range negatitvely by the provided delta, or positively if the delta is negative.

template<typename Type>
CYIRange<Type>& CYIRange< Type >::operator= ( const CYIRange< Type > &  other)
inline

Copies another range object.

template<typename Type>
bool CYIRange< Type >::operator== ( const CYIRange< Type > &  other) const
inline
template<typename Type>
void CYIRange< Type >::SetEnd ( Type  newEnd)
inline

Changes the end position of the range.

If the provided end is before the current start, the start will be changed to match the end leaving an empty range.

template<typename Type>
void CYIRange< Type >::SetLength ( Type  newLength)
inline

Changes the length of the range.

Lengths less than zero are treated as zero.

template<typename Type>
void CYIRange< Type >::SetStart ( Type  newStart)
inline

Changes the start position of the range.

If the provided start is further along than the end, the end will be changed to match the start leaving an empty range.

template<typename Type>
CYIRange<Type> CYIRange< Type >::Shifted ( Type  delta) const
inline

Moves the range up by the provided delta, or down if the delta is negative.

template<typename Type>
CYIRange<Type> CYIRange< Type >::WithEnd ( Type  newEnd) const
inline

Returns a range with the same start position as this one, but a different end.

If the new end position is below the current start of the range, the start point will be pushed back to equal the new end point.

template<typename Type>
CYIRange<Type> CYIRange< Type >::WithLength ( Type  newLength) const
inline

Returns a range with the same start as this one, but a different length.

Lengths less than zero are treated as zero.

template<typename Type>
CYIRange<Type> CYIRange< Type >::WithStart ( Type  newStart) const
inline

Returns a range with the same end as this one, but a different start.

If the new start position is higher than the current end of the range, the end point will be pushed along to equal it, returning an empty range at the new position.


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