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

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

JUCE_CONSTEXPR Range ()=default
 Constructs an empty range. More...
 
JUCE_CONSTEXPR Range (const ValueType startValue, const ValueType endValue) noexcept
 Constructs a range with given start and end values. More...
 
JUCE_CONSTEXPR Range (const Range &)=default
 Constructs a copy of another range. More...
 
Rangeoperator= (const Range &)=default
 Copies another range object. More...
 
JUCE_CONSTEXPR ValueType getStart () const noexcept
 Returns the start of the range. More...
 
JUCE_CONSTEXPR ValueType getLength () const noexcept
 Returns the length of the range. More...
 
JUCE_CONSTEXPR ValueType getEnd () const noexcept
 Returns the end of the range. More...
 
JUCE_CONSTEXPR bool isEmpty () const noexcept
 Returns true if the range has a length of zero. More...
 
void setStart (const ValueType newStart) noexcept
 Changes the start position of the range, leaving the end position unchanged. More...
 
JUCE_CONSTEXPR Range withStart (const ValueType newStart) const noexcept
 Returns a range with the same end as this one, but a different start. More...
 
JUCE_CONSTEXPR 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...
 
void setEnd (const ValueType newEnd) noexcept
 Changes the end position of the range, leaving the start unchanged. More...
 
JUCE_CONSTEXPR Range withEnd (const ValueType newEnd) const noexcept
 Returns a range with the same start position as this one, but a different end. More...
 
JUCE_CONSTEXPR 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...
 
void setLength (const ValueType newLength) noexcept
 Changes the length of the range. More...
 
JUCE_CONSTEXPR Range withLength (const ValueType newLength) const noexcept
 Returns a range with the same start as this one, but a different length. More...
 
JUCE_CONSTEXPR 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...
 
Range operator+= (const ValueType amountToAdd) noexcept
 Adds an amount to the start and end of the range. More...
 
Range operator-= (const ValueType amountToSubtract) noexcept
 Subtracts an amount from the start and end of the range. More...
 
JUCE_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.
 
JUCE_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...
 
JUCE_CONSTEXPR bool operator== (Range other) const noexcept
 
JUCE_CONSTEXPR bool operator!= (Range other) const noexcept
 
JUCE_CONSTEXPR bool contains (const ValueType position) const noexcept
 Returns true if the given position lies inside this range. More...
 
ValueType clipValue (const ValueType value) const noexcept
 Returns the nearest value to the one supplied, which lies within the range. More...
 
JUCE_CONSTEXPR bool contains (Range other) const noexcept
 Returns true if the given range lies entirely inside this range. More...
 
JUCE_CONSTEXPR bool intersects (Range other) const noexcept
 Returns true if the given range intersects this one. More...
 
JUCE_CONSTEXPR 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...
 
JUCE_CONSTEXPR Range getUnionWith (Range other) const noexcept
 Returns the smallest range that contains both this one and the other one. More...
 
JUCE_CONSTEXPR Range getUnionWith (const ValueType valueToInclude) const noexcept
 Returns the smallest range that contains both this one and the given value. More...
 
Range constrainRange (Range rangeToConstrain) const noexcept
 Returns a given range, after moving it forwards or backwards to fit it within this range. More...
 

Static Public Member Functions

static JUCE_CONSTEXPR Range between (const ValueType position1, const ValueType position2) noexcept
 Returns the range that lies between two positions (in either order). More...
 
static Range withStartAndLength (const ValueType startValue, const ValueType length) noexcept
 Returns a range with a given start and length. More...
 
static JUCE_CONSTEXPR Range emptyRange (const ValueType start) noexcept
 Returns a range with the specified start position and a length of zero. More...
 
static Range findMinAndMax (const ValueType *values, int numValues) noexcept
 Scans an array of values for its min and max, and returns these as a Range. More...
 

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 43 of file juce_Range.h.

Constructor & Destructor Documentation

◆ Range() [1/3]

◆ Range() [2/3]

template<typename ValueType>
JUCE_CONSTEXPR juce::Range< ValueType >::Range ( const ValueType  startValue,
const ValueType  endValue 
)
inlinenoexcept

Constructs a range with given start and end values.

Definition at line 51 of file juce_Range.h.

◆ Range() [3/3]

template<typename ValueType>
JUCE_CONSTEXPR juce::Range< ValueType >::Range ( const Range< ValueType > &  )
default

Constructs a copy of another range.

Member Function Documentation

◆ operator=()

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

Copies another range object.

Referenced by juce::Range< int64 >::Range().

◆ between()

template<typename ValueType>
static JUCE_CONSTEXPR Range juce::Range< ValueType >::between ( const ValueType  position1,
const ValueType  position2 
)
inlinestaticnoexcept

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

Definition at line 63 of file juce_Range.h.

◆ withStartAndLength()

template<typename ValueType>
static Range juce::Range< ValueType >::withStartAndLength ( const ValueType  startValue,
const ValueType  length 
)
inlinestaticnoexcept

Returns a range with a given start and length.

Definition at line 70 of file juce_Range.h.

◆ emptyRange()

template<typename ValueType>
static JUCE_CONSTEXPR Range juce::Range< ValueType >::emptyRange ( const ValueType  start)
inlinestaticnoexcept

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

Definition at line 77 of file juce_Range.h.

◆ getStart()

template<typename ValueType>
JUCE_CONSTEXPR ValueType juce::Range< ValueType >::getStart ( ) const
inlinenoexcept

◆ getLength()

template<typename ValueType>
JUCE_CONSTEXPR ValueType juce::Range< ValueType >::getLength ( ) const
inlinenoexcept

Returns the length of the range.

Definition at line 87 of file juce_Range.h.

Referenced by juce::Range< int64 >::constrainRange().

◆ getEnd()

template<typename ValueType>
JUCE_CONSTEXPR ValueType juce::Range< ValueType >::getEnd ( ) const
inlinenoexcept

◆ isEmpty()

template<typename ValueType>
JUCE_CONSTEXPR bool juce::Range< ValueType >::isEmpty ( ) const
inlinenoexcept

Returns true if the range has a length of zero.

Definition at line 93 of file juce_Range.h.

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

◆ 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 100 of file juce_Range.h.

◆ withStart()

template<typename ValueType>
JUCE_CONSTEXPR Range juce::Range< ValueType >::withStart ( const ValueType  newStart) const
inlinenoexcept

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 111 of file juce_Range.h.

◆ movedToStartAt()

template<typename ValueType>
JUCE_CONSTEXPR Range juce::Range< ValueType >::movedToStartAt ( const ValueType  newStart) const
inlinenoexcept

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

Definition at line 117 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 126 of file juce_Range.h.

◆ withEnd()

template<typename ValueType>
JUCE_CONSTEXPR Range juce::Range< ValueType >::withEnd ( const ValueType  newEnd) const
inlinenoexcept

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 137 of file juce_Range.h.

◆ movedToEndAt()

template<typename ValueType>
JUCE_CONSTEXPR Range juce::Range< ValueType >::movedToEndAt ( const ValueType  newEnd) const
inlinenoexcept

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

Definition at line 143 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 151 of file juce_Range.h.

◆ withLength()

template<typename ValueType>
JUCE_CONSTEXPR Range juce::Range< ValueType >::withLength ( const ValueType  newLength) const
inlinenoexcept

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 159 of file juce_Range.h.

◆ expanded()

template<typename ValueType>
JUCE_CONSTEXPR Range juce::Range< ValueType >::expanded ( ValueType  amount) const
inlinenoexcept

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 168 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 175 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 183 of file juce_Range.h.

◆ operator-()

template<typename ValueType>
JUCE_CONSTEXPR Range juce::Range< ValueType >::operator- ( const ValueType  amountToSubtract) const
inlinenoexcept

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

Definition at line 200 of file juce_Range.h.

◆ contains() [1/2]

template<typename ValueType>
JUCE_CONSTEXPR bool juce::Range< ValueType >::contains ( const ValueType  position) const
inlinenoexcept

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 213 of file juce_Range.h.

Referenced by juce::SparseSet< Type >::removeRange(), and juce::MemoryMappedAudioFormatReader::touchSample().

◆ 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 219 of file juce_Range.h.

◆ contains() [2/2]

template<typename ValueType>
JUCE_CONSTEXPR bool juce::Range< ValueType >::contains ( Range< ValueType >  other) const
inlinenoexcept

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

Definition at line 225 of file juce_Range.h.

◆ intersects()

template<typename ValueType>
JUCE_CONSTEXPR bool juce::Range< ValueType >::intersects ( Range< ValueType >  other) const
inlinenoexcept

Returns true if the given range intersects this one.

Definition at line 231 of file juce_Range.h.

◆ getIntersectionWith()

template<typename ValueType>
JUCE_CONSTEXPR Range juce::Range< ValueType >::getIntersectionWith ( Range< ValueType >  other) const
inlinenoexcept

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 238 of file juce_Range.h.

◆ getUnionWith() [1/2]

template<typename ValueType>
JUCE_CONSTEXPR Range juce::Range< ValueType >::getUnionWith ( Range< ValueType >  other) const
inlinenoexcept

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

Definition at line 245 of file juce_Range.h.

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

◆ getUnionWith() [2/2]

template<typename ValueType>
JUCE_CONSTEXPR Range juce::Range< ValueType >::getUnionWith ( const ValueType  valueToInclude) const
inlinenoexcept

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

Definition at line 252 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 268 of file juce_Range.h.

◆ findMinAndMax()

template<typename ValueType>
static Range juce::Range< ValueType >::findMinAndMax ( const ValueType *  values,
int  numValues 
)
inlinestaticnoexcept

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

Definition at line 277 of file juce_Range.h.

Referenced by juce::FloatVectorOperations::findMinAndMax(), and juce::AudioFormatReader::readMaxLevels().


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