A general-purpose range object, that simply represents any linear range with a start and end point.
More...
|
| | Range () noexcept |
| | Constructs an empty range.
|
| |
| | Range (const ValueType startValue, const ValueType endValue) noexcept |
| | Constructs a range with given start and end values.
|
| |
| | Range (const Range &other) noexcept |
| | Constructs a copy of another range.
|
| |
| Range & | operator= (const Range &other) noexcept |
| | Copies another range object.
|
| |
| | ~Range () noexcept |
| | Destructor.
|
| |
| ValueType | getStart () const noexcept |
| | Returns the start of the range.
|
| |
| ValueType | getLength () const noexcept |
| | Returns the length of the range.
|
| |
| ValueType | getEnd () const noexcept |
| | Returns the end of the range.
|
| |
| bool | isEmpty () const noexcept |
| | Returns true if the range has a length of zero.
|
| |
| void | setStart (const ValueType newStart) noexcept |
| | Changes the start position of the range, leaving the end position unchanged.
|
| |
| Range | withStart (const ValueType newStart) const noexcept |
| | Returns a range with the same end as this one, but a different start.
|
| |
| Range | movedToStartAt (const ValueType newStart) const noexcept |
| | Returns a range with the same length as this one, but moved to have the given start position.
|
| |
| void | setEnd (const ValueType newEnd) noexcept |
| | Changes the end position of the range, leaving the start unchanged.
|
| |
| Range | withEnd (const ValueType newEnd) const noexcept |
| | Returns a range with the same start position as this one, but a different end.
|
| |
| Range | movedToEndAt (const ValueType newEnd) const noexcept |
| | Returns a range with the same length as this one, but moved to have the given end position.
|
| |
| void | setLength (const ValueType newLength) noexcept |
| | Changes the length of the range.
|
| |
| Range | withLength (const ValueType newLength) const noexcept |
| | Returns a range with the same start as this one, but a different length.
|
| |
| const Range & | operator+= (const ValueType amountToAdd) noexcept |
| | Adds an amount to the start and end of the range.
|
| |
| const Range & | operator-= (const ValueType amountToSubtract) noexcept |
| | Subtracts an amount from the start and end of the range.
|
| |
| Range | operator+ (const ValueType amountToAdd) const noexcept |
| | Returns a range that is equal to this one with an amount added to its start and end.
|
| |
| Range | operator- (const ValueType amountToSubtract) const noexcept |
| | Returns a range that is equal to this one with the specified amount subtracted from its start and end.
|
| |
| bool | operator== (const Range &other) const noexcept |
| |
| bool | operator!= (const Range &other) const noexcept |
| |
| bool | contains (const ValueType position) const noexcept |
| | Returns true if the given position lies inside this range.
|
| |
| ValueType | clipValue (const ValueType value) const noexcept |
| | Returns the nearest value to the one supplied, which lies within the range.
|
| |
| bool | contains (const Range &other) const noexcept |
| | Returns true if the given range lies entirely inside this range.
|
| |
| bool | intersects (const Range &other) const noexcept |
| | Returns true if the given range intersects this one.
|
| |
| Range | getIntersectionWith (const Range &other) const noexcept |
| | Returns the range that is the intersection of the two ranges, or an empty range with an undefined start position if they don't overlap.
|
| |
| Range | getUnionWith (const Range &other) const noexcept |
| | Returns the smallest range that contains both this one and the other one.
|
| |
| Range | constrainRange (const Range &rangeToConstrain) const noexcept |
| | Returns a given range, after moving it forwards or backwards to fit it within this range.
|
| |
template<typename ValueType>
class Range< ValueType >
A general-purpose range object, that simply represents any linear range with a start and end point.
The templated parameter is expected to be a primitive integer or floating point type, though class types could also be used if they behave in a number-like way.
template<typename ValueType>
| Range Range< ValueType >::constrainRange |
( |
const Range< ValueType > & |
rangeToConstrain | ) |
const |
|
noexcept |
Returns a given range, after moving it forwards or backwards to fit it within this range.
If the supplied range has a greater length than this one, the return value will be this range.
Otherwise, if the supplied range is smaller than this one, the return value will be the new range, shifted forwards or backwards so that it doesn't extend beyond this one, but keeping its original length.