54 void clear() { ranges.clear(); }
71 for (
auto& r : ranges)
72 total += r.getLength();
86 for (
auto& r : ranges)
91 return r.getStart() + (index -
total);
102 for (
auto& r : ranges)
132 if (ranges.isEmpty())
135 return { ranges.getFirst().getStart(),
136 ranges.getLast().getEnd() };
162 for (
int i = ranges.size(); --i >= 0;)
164 auto& r = ranges.getReference (i);
189 if (!
r1.isEmpty() && !
r2.isEmpty())
190 ranges.insert (i + 1,
r2);
210 for (
auto& r : ranges)
222 if (! range.isEmpty())
223 for (
auto& r : ranges)
224 if (r.intersects (range))
233 if (! range.isEmpty())
234 for (
auto& r : ranges)
235 if (r.contains (range))
246 bool operator!= (
const SparseSet&
other)
const noexcept {
return ranges !=
other.ranges; }
254 for (
int i = ranges.size(); --i > 0;)
256 auto&
r1 = ranges.getReference (i - 1);
257 auto&
r2 = ranges.getReference (i);
259 if (
r1.getEnd() ==
r2.getStart())
261 r1.setEnd (
r2.getEnd());
Holds a resizable array of primitive or copy-by-value objects.
A general-purpose range object, that simply represents any linear range with a start and end point.
constexpr bool isEmpty() const noexcept
Returns true if the range has a length of zero.
Holds a set of primitive values, storing them as a set of ranges.
Range< Type > getRange(int rangeIndex) const noexcept
Returns one of the contiguous ranges of values stored.
void invertRange(Range< Type > range)
Does an XOR of the values in a given range.
void clear()
Clears the set.
bool overlapsRange(Range< Type > range) const noexcept
Checks whether any part of a given range overlaps any part of this set.
Type size() const noexcept
Returns the number of values in the set.
void addRange(Range< Type > range)
Adds a range of contiguous values to the set.
bool isEmpty() const noexcept
Checks whether the set is empty.
Type operator[](Type index) const noexcept
Returns one of the values in the set.
bool contains(Type valueToLookFor) const noexcept
Checks whether a particular value is in the set.
int getNumRanges() const noexcept
Returns the number of contiguous blocks of values.
const Array< Range< Type > > & getRanges() const noexcept
Returns the set as a list of ranges, which you may want to iterate over.
Range< Type > getTotalRange() const noexcept
Returns the range between the lowest and highest values in the set.
bool containsRange(Range< Type > range) const noexcept
Checks whether the whole of a given range is contained within this one.
void removeRange(Range< Type > rangeToRemove)
Removes a range of values from the set.
RangedDirectoryIterator end(const RangedDirectoryIterator &)
Returns a default-constructed sentinel value.
Type unalignedPointerCast(void *ptr) noexcept
Casts a pointer to another type via void*, which suppresses the cast-align warning which sometimes ar...