OpenShot Audio Library | OpenShotAudio: juce::Range< ValueType > Class Template Reference

OpenShot Audio Library | OpenShotAudio 1.0.0

Loading...
Searching...
No Matches
juce::Range< ValueType > Class Template Reference

`#include <juce_Range.h>`

## Public Member Functions
constexpr | Range ()=default
constexpr | Range (const ValueType startValue, const ValueType endValue) noexcept
constexpr | Range (const Range &)=default
Range & | operator= (const Range &)=default
constexpr ValueType | getStart () const noexcept
constexpr ValueType | getLength () const noexcept
constexpr ValueType | getEnd () const noexcept
constexpr bool | isEmpty () const noexcept
void | setStart (const ValueType newStart) noexcept
constexpr Range | withStart (const ValueType newStart) const noexcept
constexpr Range | movedToStartAt (const ValueType newStart) const noexcept
void | setEnd (const ValueType newEnd) noexcept
constexpr Range | withEnd (const ValueType newEnd) const noexcept
constexpr Range | movedToEndAt (const ValueType newEnd) const noexcept
void | setLength (const ValueType newLength) noexcept
constexpr Range | withLength (const ValueType newLength) const noexcept
constexpr Range | expanded (ValueType amount) const noexcept
Range | operator+= (const ValueType amountToAdd) noexcept
Range | operator-= (const ValueType amountToSubtract) noexcept
constexpr Range | operator+ (const ValueType amountToAdd) const noexcept
constexpr Range | operator- (const ValueType amountToSubtract) const noexcept
constexpr bool | operator== (Range other) const noexcept
constexpr bool | operator!= (Range other) const noexcept
constexpr bool | contains (const ValueType position) const noexcept
ValueType | clipValue (const ValueType value) const noexcept
constexpr bool | contains (Range other) const noexcept
constexpr bool | intersects (Range other) const noexcept
constexpr Range | getIntersectionWith (Range other) const noexcept
constexpr Range | getUnionWith (Range other) const noexcept
constexpr Range | getUnionWith (const ValueType valueToInclude) const noexcept
Range | constrainRange (Range rangeToConstrain) const noexcept

## Static Public Member Functions
static constexpr Range | between (const ValueType position1, const ValueType position2) noexcept
static Range | withStartAndLength (const ValueType startValue, const ValueType length) noexcept
static constexpr Range | emptyRange (const ValueType start) noexcept
template<typename Integral, std::enable_if_t< std::is_integral_v< Integral >, int > = 0>
static Range | findMinAndMax (const ValueType *values, Integral numValues) noexcept

## Detailed Description

template<typename ValueType>
class juce::Range< ValueType >

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.

Definition at line 39 of file juce_Range.h.

## Constructor & Destructor Documentation

## ◆ Range() [1/3]

template<typename ValueType>

juce::Range< ValueType >::Range | ( |  | ) |
| constexprdefault

Constructs an empty range.

Referenced by between(), constrainRange(), contains(), emptyRange(), expanded(), findMinAndMax(), getIntersectionWith(), getUnionWith(), getUnionWith(), intersects(), movedToEndAt(), movedToStartAt(), operator+(), operator+=(), operator-(), operator-=(), operator=(), Range(), juce::AudioFormatReader::readMaxLevels(), withEnd(), withLength(), withStart(), and withStartAndLength().

## ◆ Range() [2/3]

template<typename ValueType>

juce::Range< ValueType >::Range | ( | const ValueType | startValue,
|  | const ValueType | endValue )
| inlineconstexprnoexcept

Constructs a range with given start and end values.

Definition at line 47 of file juce_Range.h.

## ◆ Range() [3/3]

template<typename ValueType>

juce::Range< ValueType >::Range | ( | const Range< ValueType > & |  | ) |
| constexprdefault

Constructs a copy of another range.

## Member Function Documentation

## ◆ between()

template<typename ValueType>

constexpr Range juce::Range< ValueType >::between | ( | const ValueType | position1,
|  | const ValueType | position2 )
| inlinestaticconstexprnoexcept

Returns the range that lies between two positions (in either order).

Definition at line 59 of file juce_Range.h.

## ◆ clipValue()

template<typename ValueType>

ValueType juce::Range< ValueType >::clipValue | ( | const ValueType | value | ) | const
| inlinenoexcept

Returns the nearest value to the one supplied, which lies within the range.

Definition at line 220 of file juce_Range.h.

## ◆ constrainRange()

template<typename ValueType>

Range juce::Range< ValueType >::constrainRange | ( | Range< ValueType > | rangeToConstrain | ) | const
| 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.

Definition at line 269 of file juce_Range.h.

## ◆ contains() [1/2]

template<typename ValueType>

bool juce::Range< ValueType >::contains | ( | const ValueType | position | ) | const
| 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.

Definition at line 214 of file juce_Range.h.

Referenced by juce::SparseSet< Type >::removeRange().

## ◆ contains() [2/2]

template<typename ValueType>

bool juce::Range< ValueType >::contains | ( | Range< ValueType > | other | ) | const
| inlineconstexprnoexcept

Returns true if the given range lies entirely inside this range.

Definition at line 226 of file juce_Range.h.

## ◆ emptyRange()

template<typename ValueType>

constexpr Range juce::Range< ValueType >::emptyRange | ( | const ValueType | start | ) |
| inlinestaticnodiscardconstexprnoexcept

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

Definition at line 73 of file juce_Range.h.

## ◆ expanded()

template<typename ValueType>

Range juce::Range< ValueType >::expanded | ( | ValueType | amount | ) | const
| inlinenodiscardconstexprnoexcept

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

Returns
  The returned range will be (start - amount, end + amount)

Definition at line 164 of file juce_Range.h.

## ◆ findMinAndMax()

template<typename ValueType>
template<typename Integral, std::enable_if_t< std::is_integral_v< Integral >, int > = 0>

Range juce::Range< ValueType >::findMinAndMax | ( | const ValueType * | values,
|  | Integral | numValues )
| inlinestaticnoexcept

Scans an array of values for its min and max, and returns these as a Range.

Definition at line 279 of file juce_Range.h.

Referenced by juce::AudioFormatReader::readMaxLevels().

## ◆ getEnd()

template<typename ValueType>

ValueType juce::Range< ValueType >::getEnd | ( |  | ) | const
| inlineconstexprnoexcept

Returns the end of the range.

Definition at line 86 of file juce_Range.h.

Referenced by juce::AudioData::Pointer< DataFormat, Endianness, std::conditional_t< IsInterleaved, Interleaved, NonInterleaved >, std::conditional_t< IsConst, Const, NonConst > >::findMinAndMax(), juce::MemoryMappedAudioFormatReader::mapSectionOfFile(), juce::AudioFormatReader::readMaxLevels(), and juce::SparseSet< Type >::removeRange().

## ◆ getIntersectionWith()

template<typename ValueType>

Range juce::Range< ValueType >::getIntersectionWith | ( | Range< ValueType > | other | ) | const
| inlinenodiscardconstexprnoexcept

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.

Definition at line 239 of file juce_Range.h.

Referenced by juce::Reservoir::doBufferedRead().

## ◆ getLength()

template<typename ValueType>

ValueType juce::Range< ValueType >::getLength | ( |  | ) | const
| inlineconstexprnoexcept

Returns the length of the range.

Definition at line 83 of file juce_Range.h.

Referenced by constrainRange().

## ◆ getStart()

template<typename ValueType>

ValueType juce::Range< ValueType >::getStart | ( |  | ) | const
| inlineconstexprnoexcept

Returns the start of the range.

Definition at line 80 of file juce_Range.h.

Referenced by juce::Reservoir::doBufferedRead(), juce::AudioData::Pointer< DataFormat, Endianness, std::conditional_t< IsInterleaved, Interleaved, NonInterleaved >, std::conditional_t< IsConst, Const, NonConst > >::findMinAndMax(), juce::MemoryMappedAudioFormatReader::mapSectionOfFile(), juce::AudioFormatReader::readMaxLevels(), and juce::SparseSet< Type >::removeRange().

## ◆ getUnionWith() [1/2]

template<typename ValueType>

Range juce::Range< ValueType >::getUnionWith | ( | const ValueType | valueToInclude | ) | const
| inlinenodiscardconstexprnoexcept

Returns the smallest range that contains both this one and the given value.

Definition at line 253 of file juce_Range.h.

## ◆ getUnionWith() [2/2]

template<typename ValueType>

Range juce::Range< ValueType >::getUnionWith | ( | Range< ValueType > | other | ) | const
| inlinenodiscardconstexprnoexcept

Returns the smallest range that contains both this one and the other one.

Definition at line 246 of file juce_Range.h.

Referenced by juce::AudioFormatReader::readMaxLevels().

## ◆ intersects()

template<typename ValueType>

bool juce::Range< ValueType >::intersects | ( | Range< ValueType > | other | ) | const
| inlineconstexprnoexcept

Returns true if the given range intersects this one.

Definition at line 232 of file juce_Range.h.

## ◆ isEmpty()

template<typename ValueType>

bool juce::Range< ValueType >::isEmpty | ( |  | ) | const
| inlineconstexprnoexcept

Returns true if the range has a length of zero.

Definition at line 89 of file juce_Range.h.

Referenced by juce::SparseSet< Type >::addRange(), juce::Reservoir::doBufferedRead(), juce::MPEChannelAssigner::MPEChannelAssigner(), and juce::SparseSet< Type >::removeRange().

## ◆ movedToEndAt()

template<typename ValueType>

Range juce::Range< ValueType >::movedToEndAt | ( | const ValueType | newEnd | ) | const
| inlinenodiscardconstexprnoexcept

Returns a range with the same length as this one, but moved to have the given end position.

Definition at line 139 of file juce_Range.h.

## ◆ movedToStartAt()

template<typename ValueType>

Range juce::Range< ValueType >::movedToStartAt | ( | const ValueType | newStart | ) | const
| inlinenodiscardconstexprnoexcept

Returns a range with the same length as this one, but moved to have the given start position.

Definition at line 113 of file juce_Range.h.

## ◆ operator!=()

template<typename ValueType>

bool juce::Range< ValueType >::operator!= | ( | Range< ValueType > | other | ) | const
| inlineconstexprnoexcept

Definition at line 207 of file juce_Range.h.

## ◆ operator+()

template<typename ValueType>

Range juce::Range< ValueType >::operator+ | ( | const ValueType | amountToAdd | ) | const
| inlineconstexprnoexcept

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

Definition at line 189 of file juce_Range.h.

## ◆ operator+=()

template<typename ValueType>

Range juce::Range< ValueType >::operator+= | ( | const ValueType | amountToAdd | ) |
| inlinenoexcept

Adds an amount to the start and end of the range.

Definition at line 171 of file juce_Range.h.

## ◆ operator-()

template<typename ValueType>

Range juce::Range< ValueType >::operator- | ( | const ValueType | amountToSubtract | ) | const
| inlineconstexprnoexcept

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

Definition at line 196 of file juce_Range.h.

## ◆ operator-=()

template<typename ValueType>

Range juce::Range< ValueType >::operator-= | ( | const ValueType | amountToSubtract | ) |
| inlinenoexcept

Subtracts an amount from the start and end of the range.

Definition at line 179 of file juce_Range.h.

## ◆ operator=()

template<typename ValueType>

Range & juce::Range< ValueType >::operator= | ( | const Range< ValueType > & |  | ) |
| default

Copies another range object.

## ◆ operator==()

template<typename ValueType>

bool juce::Range< ValueType >::operator== | ( | Range< ValueType > | other | ) | const
| inlineconstexprnoexcept

Definition at line 201 of file juce_Range.h.

## ◆ setEnd()

template<typename ValueType>

void juce::Range< ValueType >::setEnd | ( | const ValueType | newEnd | ) |
| 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.

Definition at line 122 of file juce_Range.h.

## ◆ setLength()

template<typename ValueType>

void juce::Range< ValueType >::setLength | ( | const ValueType | newLength | ) |
| inlinenoexcept

Changes the length of the range. Lengths less than zero are treated as zero.

Definition at line 147 of file juce_Range.h.

## ◆ setStart()

template<typename ValueType>

void juce::Range< ValueType >::setStart | ( | const ValueType | newStart | ) |
| 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.

Definition at line 96 of file juce_Range.h.

Referenced by juce::Reservoir::doBufferedRead().

## ◆ withEnd()

template<typename ValueType>

Range juce::Range< ValueType >::withEnd | ( | const ValueType | newEnd | ) | const
| inlinenodiscardconstexprnoexcept

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.

Definition at line 133 of file juce_Range.h.

## ◆ withLength()

template<typename ValueType>

Range juce::Range< ValueType >::withLength | ( | const ValueType | newLength | ) | const
| inlinenodiscardconstexprnoexcept

Returns a range with the same start as this one, but a different length. Lengths less than zero are treated as zero.

Definition at line 155 of file juce_Range.h.

## ◆ withStart()

template<typename ValueType>

Range juce::Range< ValueType >::withStart | ( | const ValueType | newStart | ) | const
| inlinenodiscardconstexprnoexcept

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.

Definition at line 107 of file juce_Range.h.

## ◆ withStartAndLength()

template<typename ValueType>

Range juce::Range< ValueType >::withStartAndLength | ( | const ValueType | startValue,
|  | const ValueType | length )
| inlinestaticnodiscardnoexcept

Returns a range with a given start and length.

Definition at line 66 of file juce_Range.h.

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

- juce_Range.h