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.
#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) |
Constructs a range with given lhs and rhs values. The order doesn't matter.
Constructs a copy of another range.
|
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.
|
inlinestatic |
Returns a range with the specified start position and a length of zero.
|
inlinestatic |
Returns a range with a given start and length.
Returns a range which has its start moved down and its end moved up by the given amount.
|
inline |
Returns the end of the range.
|
inline |
Returns the length of the range.
|
inline |
Returns the start of the range.
| bool CYIRange< Type >::IsEmpty | ( | ) | const |
Returns true if the range has a length of zero.
|
inline |
Returns true if the range has a non-zero length.
|
inline |
Returns a range that is equal to this one with an amount added to its start and end.
Moves the range positively by the provided delta, or negatitvely if the delta is negative.
Returns a range that is equal to this one with an amount subtracted to its start and end.
Moves the range negatitvely by the provided delta, or positively if the delta is negative.
|
inline |
Copies another range object.
|
inline |
|
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.
|
inline |
Changes the length of the range.
Lengths less than zero are treated as zero.
|
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.
Moves the range up by the provided delta, or down if the delta is negative.
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.
Returns a range with the same start as this one, but a different length.
Lengths less than zero are treated as zero.
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.