A general-purpose range object, that simply represents any linear range with a start and end point. More...
#include <juce_Range.h>
Public Member Functions | |
constexpr | Range ()=default |
Constructs an empty range. More... | |
constexpr | Range (const Range &)=default |
Constructs a copy of another range. More... | |
constexpr | Range (const ValueType startValue, const ValueType endValue) noexcept |
Constructs a range with given start and end values. More... | |
ValueType | clipValue (const ValueType value) const noexcept |
Returns the nearest value to the one supplied, which lies within the range. More... | |
Range | constrainRange (Range rangeToConstrain) const noexcept |
Returns a given range, after moving it forwards or backwards to fit it within this range. More... | |
constexpr bool | contains (const ValueType position) const noexcept |
Returns true if the given position lies inside this range. More... | |
constexpr bool | contains (Range other) const noexcept |
Returns true if the given range lies entirely inside this range. More... | |
constexpr JUCE_NODISCARD Range | expanded (ValueType amount) const noexcept |
Returns a range which has its start moved down and its end moved up by the given amount. More... | |
constexpr ValueType | getEnd () const noexcept |
Returns the end of the range. More... | |
constexpr JUCE_NODISCARD Range | getIntersectionWith (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. More... | |
constexpr ValueType | getLength () const noexcept |
Returns the length of the range. More... | |
constexpr ValueType | getStart () const noexcept |
Returns the start of the range. More... | |
constexpr JUCE_NODISCARD Range | getUnionWith (const ValueType valueToInclude) const noexcept |
Returns the smallest range that contains both this one and the given value. More... | |
constexpr JUCE_NODISCARD Range | getUnionWith (Range other) const noexcept |
Returns the smallest range that contains both this one and the other one. More... | |
constexpr bool | intersects (Range other) const noexcept |
Returns true if the given range intersects this one. More... | |
constexpr bool | isEmpty () const noexcept |
Returns true if the range has a length of zero. More... | |
constexpr JUCE_NODISCARD 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. More... | |
constexpr JUCE_NODISCARD 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. More... | |
constexpr bool | operator!= (Range other) const noexcept |
constexpr 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. More... | |
Range | operator+= (const ValueType amountToAdd) noexcept |
Adds an amount to the start and end of the range. More... | |
constexpr 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. More... | |
Range | operator-= (const ValueType amountToSubtract) noexcept |
Subtracts an amount from the start and end of the range. More... | |
Range & | operator= (const Range &)=default |
Copies another range object. More... | |
constexpr bool | operator== (Range other) const noexcept |
void | setEnd (const ValueType newEnd) noexcept |
Changes the end position of the range, leaving the start unchanged. More... | |
void | setLength (const ValueType newLength) noexcept |
Changes the length of the range. More... | |
void | setStart (const ValueType newStart) noexcept |
Changes the start position of the range, leaving the end position unchanged. More... | |
constexpr JUCE_NODISCARD Range | withEnd (const ValueType newEnd) const noexcept |
Returns a range with the same start position as this one, but a different end. More... | |
constexpr JUCE_NODISCARD Range | withLength (const ValueType newLength) const noexcept |
Returns a range with the same start as this one, but a different length. More... | |
constexpr JUCE_NODISCARD Range | withStart (const ValueType newStart) const noexcept |
Returns a range with the same end as this one, but a different start. More... | |
Static Public Member Functions | |
constexpr static Range | between (const ValueType position1, const ValueType position2) noexcept |
Returns the range that lies between two positions (in either order). More... | |
constexpr static JUCE_NODISCARD Range | emptyRange (const ValueType start) noexcept |
Returns a range with the specified start position and a length of zero. More... | |
template<typename Integral , std::enable_if_t< std::is_integral< Integral >::value, int > = 0> | |
static Range | findMinAndMax (const ValueType *values, Integral numValues) noexcept |
Scans an array of values for its min and max, and returns these as a Range. More... | |
static JUCE_NODISCARD Range | withStartAndLength (const ValueType startValue, const ValueType length) noexcept |
Returns a range with a given start and length. More... | |
Private Attributes | |
ValueType | end {} |
ValueType | start {} |
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 integer or floating point type, though class types could also be used if they behave in a number-like way.
@tags{Core}
|
constexprdefault |
Constructs an empty range.
Referenced by juce::Range< int64 >::between(), juce::Range< int64 >::emptyRange(), juce::Range< int64 >::expanded(), juce::Range< int64 >::findMinAndMax(), juce::Range< int64 >::getIntersectionWith(), juce::Range< int64 >::getUnionWith(), juce::Range< int64 >::movedToEndAt(), juce::Range< int64 >::movedToStartAt(), juce::Range< int64 >::operator+(), juce::Range< int64 >::operator-(), juce::Range< int64 >::withEnd(), juce::Range< int64 >::withLength(), juce::Range< int64 >::withStart(), and juce::Range< int64 >::withStartAndLength().
|
inlineconstexprnoexcept |
Constructs a range with given start and end values.
|
constexprdefault |
Constructs a copy of another range.
|
inlinestaticconstexprnoexcept |
Returns the range that lies between two positions (in either order).
|
inlinenoexcept |
Returns the nearest value to the one supplied, which lies within the range.
Referenced by juce::AnimatedPosition< Behaviour >::setPositionAndSendChange().
|
inlinenoexcept |
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.
|
inlineconstexprnoexcept |
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.
Referenced by juce::SparseSet< int >::removeRange().
|
inlineconstexprnoexcept |
Returns true if the given range lies entirely inside this range.
|
inlinestaticconstexprnoexcept |
Returns a range with the specified start position and a length of zero.
|
inlineconstexprnoexcept |
Returns a range which has its start moved down and its end moved up by the given amount.
|
inlinestaticnoexcept |
Scans an array of values for its min and max, and returns these as a Range.
|
inlineconstexprnoexcept |
|
inlineconstexprnoexcept |
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.
Referenced by juce::Reservoir::doBufferedRead().
|
inlineconstexprnoexcept |
Returns the length of the range.
Referenced by juce::Range< int64 >::constrainRange(), juce::MemoryMappedFile::openInternal(), and juce::MemoryMappedFile::~MemoryMappedFile().
|
inlineconstexprnoexcept |
Returns the start of the range.
Referenced by juce::UIATextProvider::UIATextRangeProvider::CompareEndpoints(), juce::Reservoir::doBufferedRead(), juce::UIATextProvider::UIATextRangeProvider::ExpandToEnclosingUnit(), juce::UIATextProvider::UIATextRangeProvider::MoveEndpointByUnit(), juce::MemoryMappedFile::openInternal(), juce::SparseSet< int >::removeRange(), and juce::UIATextProvider::UIATextRangeProvider::setEndpointChecked().
|
inlineconstexprnoexcept |
Returns the smallest range that contains both this one and the given value.
|
inlineconstexprnoexcept |
Returns the smallest range that contains both this one and the other one.
|
inlineconstexprnoexcept |
Returns true if the given range intersects this one.
|
inlineconstexprnoexcept |
Returns true if the range has a length of zero.
Referenced by juce::Reservoir::doBufferedRead(), juce::UIATextProvider::GetSelection(), and juce::SparseSet< int >::removeRange().
|
inlineconstexprnoexcept |
Returns a range with the same length as this one, but moved to have the given end position.
|
inlineconstexprnoexcept |
Returns a range with the same length as this one, but moved to have the given start position.
|
inlineconstexprnoexcept |
|
inlineconstexprnoexcept |
Returns a range that is equal to this one with an amount added to its start and end.
|
inlinenoexcept |
Adds an amount to the start and end of the range.
|
inlineconstexprnoexcept |
Returns a range that is equal to this one with the specified amount subtracted from its start and end.
|
inlinenoexcept |
Subtracts an amount from the start and end of the range.
|
default |
Copies another range object.
|
inlineconstexprnoexcept |
|
inlinenoexcept |
Changes the end position of the range, leaving the start unchanged.
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.
Referenced by juce::UIATextProvider::UIATextRangeProvider::setEndpointChecked().
|
inlinenoexcept |
Changes the length of the range.
Lengths less than zero are treated as zero.
|
inlinenoexcept |
Changes the start position of the range, leaving the end position unchanged.
If the new start position is higher than the current end of the range, the end point will be pushed along to equal it, leaving an empty range at the new position.
Referenced by juce::Reservoir::doBufferedRead(), juce::MemoryMappedFile::openInternal(), and juce::UIATextProvider::UIATextRangeProvider::setEndpointChecked().
|
inlineconstexprnoexcept |
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.
|
inlineconstexprnoexcept |
Returns a range with the same start as this one, but a different length.
Lengths less than zero are treated as zero.
|
inlineconstexprnoexcept |
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.
|
inlinestaticnoexcept |
Returns a range with a given start and length.
Referenced by juce::Rectangle< int >::getHorizontalRange(), and juce::Rectangle< int >::getVerticalRange().
|
private |
Referenced by juce::Range< int64 >::clipValue(), juce::Range< int64 >::constrainRange(), juce::Range< int64 >::contains(), juce::Range< int64 >::expanded(), juce::Range< int64 >::getEnd(), juce::Range< int64 >::getIntersectionWith(), juce::Range< int64 >::getLength(), juce::Range< int64 >::getUnionWith(), juce::Range< int64 >::intersects(), juce::Range< int64 >::isEmpty(), juce::Range< int64 >::movedToEndAt(), juce::Range< int64 >::movedToStartAt(), juce::Range< int64 >::operator!=(), juce::Range< int64 >::operator+(), juce::Range< int64 >::operator+=(), juce::Range< int64 >::operator-(), juce::Range< int64 >::operator-=(), juce::Range< int64 >::operator==(), juce::Range< int64 >::setEnd(), juce::Range< int64 >::setLength(), juce::Range< int64 >::setStart(), and juce::Range< int64 >::withStart().
|
private |
Referenced by juce::Range< int64 >::clipValue(), juce::Range< int64 >::constrainRange(), juce::Range< int64 >::contains(), juce::Range< int64 >::emptyRange(), juce::Range< int64 >::expanded(), juce::Range< int64 >::getIntersectionWith(), juce::Range< int64 >::getLength(), juce::AudioParameterInt::getRange(), juce::Range< int64 >::getStart(), juce::Range< int64 >::getUnionWith(), juce::Range< int64 >::intersects(), juce::Range< int64 >::isEmpty(), juce::Range< int64 >::movedToEndAt(), juce::Range< int64 >::movedToStartAt(), juce::Range< int64 >::operator!=(), juce::Range< int64 >::operator+(), juce::Range< int64 >::operator+=(), juce::Range< int64 >::operator-(), juce::Range< int64 >::operator-=(), juce::Range< int64 >::operator==(), juce::Range< int64 >::setEnd(), juce::Range< int64 >::setLength(), juce::Range< int64 >::setStart(), juce::Range< int64 >::withEnd(), and juce::Range< int64 >::withLength().