29 #ifndef JUCE_RANGE_H_INCLUDED 30 #define JUCE_RANGE_H_INCLUDED 43 template <
typename ValueType>
55 : start (startValue), end (
jmax (startValue, endValue))
61 : start (other.start), end (other.end)
76 return position1 < position2 ?
Range (position1, position2)
77 :
Range (position2, position1);
90 return Range (start, start);
124 return Range (newStart,
jmax (newStart, end));
130 return Range (newStart, end + (newStart - start));
150 return Range (
jmin (start, newEnd), newEnd);
156 return Range (start + (newEnd - end), newEnd);
164 end = start +
jmax (ValueType(), newLength);
172 return Range (start, start + newLength);
179 start += amountToAdd;
187 start -= amountToSubtract;
188 end -= amountToSubtract;
197 return Range (start + amountToAdd, end + amountToAdd);
204 return Range (start - amountToSubtract, end - amountToSubtract);
214 return start <= position && position < end;
220 return jlimit (start, end, value);
229 return start <= other.start && end >= other.end;
235 return other.start < end && start < other.end;
243 jmin (end, other.end));
250 jmax (end, other.end));
256 return Range (
jmin (valueToInclude, start),
257 jmax (valueToInclude, end));
272 const ValueType otherLen = rangeToConstrain.getLength();
275 : rangeToConstrain.movedToStartAt (
jlimit (start, end - otherLen, rangeToConstrain.getStart()));
284 const ValueType first (*values++);
285 Range r (first, first);
287 while (--numValues > 0)
289 const ValueType v (*values++);
291 if (r.end < v) r.end = v;
292 if (v < r.start) r.start = v;
300 ValueType start, end;
304 #endif // JUCE_RANGE_H_INCLUDED Range getIntersectionWith(Range other) const noexcept
Definition: juce_Range.h:240
Range movedToStartAt(const ValueType newStart) const noexcept
Definition: juce_Range.h:128
Range movedToEndAt(const ValueType newEnd) const noexcept
Definition: juce_Range.h:154
Range operator-(const ValueType amountToSubtract) const noexcept
Definition: juce_Range.h:202
#define noexcept
Definition: juce_CompilerSupport.h:141
static Range between(const ValueType position1, const ValueType position2) noexcept
Definition: juce_Range.h:74
Range withEnd(const ValueType newEnd) const noexcept
Definition: juce_Range.h:148
Type jmin(const Type a, const Type b)
Definition: juce_core.h:113
void setEnd(const ValueType newEnd) noexcept
Definition: juce_Range.h:137
Range getUnionWith(const ValueType valueToInclude) const noexcept
Definition: juce_Range.h:254
Definition: juce_Range.h:44
bool operator==(Range other) const noexcept
Definition: juce_Range.h:207
static Range findMinAndMax(const ValueType *values, int numValues) noexcept
Definition: juce_Range.h:279
ValueType clipValue(const ValueType value) const noexcept
Definition: juce_Range.h:218
ValueType getLength() const noexcept
Definition: juce_Range.h:98
Range operator-=(const ValueType amountToSubtract) noexcept
Definition: juce_Range.h:185
void setLength(const ValueType newLength) noexcept
Definition: juce_Range.h:162
Type jmax(const Type a, const Type b)
Definition: juce_core.h:101
png_uint_32 length
Definition: juce_PNGLoader.cpp:2078
Range constrainRange(Range rangeToConstrain) const noexcept
Definition: juce_Range.h:270
static Range emptyRange(const ValueType start) noexcept
Definition: juce_Range.h:88
bool contains(const ValueType position) const noexcept
Definition: juce_Range.h:212
bool contains(Range other) const noexcept
Definition: juce_Range.h:227
Range withLength(const ValueType newLength) const noexcept
Definition: juce_Range.h:170
bool intersects(Range other) const noexcept
Definition: juce_Range.h:233
void setStart(const ValueType newStart) noexcept
Definition: juce_Range.h:111
Range getUnionWith(Range other) const noexcept
Definition: juce_Range.h:247
Type jlimit(const Type lowerLimit, const Type upperLimit, const Type valueToConstrain) noexcept
Definition: juce_MathsFunctions.h:220
static Range withStartAndLength(const ValueType startValue, const ValueType length) noexcept
Definition: juce_Range.h:81
Range(const ValueType startValue, const ValueType endValue) noexcept
Definition: juce_Range.h:54
Range operator+=(const ValueType amountToAdd) noexcept
Definition: juce_Range.h:177
Range & operator=(Range other) noexcept
Definition: juce_Range.h:66
Range(const Range &other) noexcept
Definition: juce_Range.h:60
Range withStart(const ValueType newStart) const noexcept
Definition: juce_Range.h:122
bool operator!=(Range other) const noexcept
Definition: juce_Range.h:208
ValueType getStart() const noexcept
Definition: juce_Range.h:95
bool isEmpty() const noexcept
Definition: juce_Range.h:104
Range() noexcept
Definition: juce_Range.h:49
Range operator+(const ValueType amountToAdd) const noexcept
Definition: juce_Range.h:195
ValueType getEnd() const noexcept
Definition: juce_Range.h:101