RangeSet.hpp
A collection of ranges that can be operated on collectively.
Note
Status: BETA
-
template<typename T>
class RangeSet - #include <RangeSet.hpp>
RangeSet maintains a collection of ranges. The ranges are exclusive of the endpoint and kept sorted and non-adjacent (i.e., there is a gap between successive ranges).
Public Functions
-
RangeSet() = default
- bool operator (const RangeSet &) const =default
-
inline bool IsEmpty() const
-
inline size_t GetNumRanges() const
-
inline RangeSet &Shift(T shift)
Shift all ranges by a fixed amount.
- Parameters:
shift – How much should the range be shifted by?
-
inline RangeSet &Insert(T val)
Insert a value into this range set.
- Parameters:
val – Value to insert.
- Returns:
This RangeSet after insertion.
-
inline RangeSet &Insert(range_t in)
Insert a whole range into this set, merging other ranges if needed.
- Parameters:
in – New range to include.
- Returns:
This RangeSet after insertion.
-
inline RangeSet &Insert(const this_t &in_set)
Merge an entire range set into this one.
Note
Can be optimized to handle big set mergers more efficiently!
- Parameters:
in_set – Range set to add in.
- Returns:
This RangeSet after insertion.
-
inline RangeSet &InsertRange(T start, T stop)
Insert a range into this set, specifying the start and end points.
- Parameters:
start – Beginning of new range to include.
stop – Ending of new range to include (range is not inclusive of stop)
- Returns:
This RangeSet after insertion.
-
inline RangeSet &Remove(T val)
Remove a single value from this RangeSet.
- Parameters:
val – Value to remove
- Returns:
This RangeSet after removal.
-
inline RangeSet &RemoveTo(T val)
Remove all ranges (or partial range) less than a target value.
- Parameters:
val – New floor for ranges.
- Returns:
This RangeSet after removal.
-
inline RangeSet &RemoveFrom(T val)
Remove all ranges (or partial range) greater than a target value.
- Parameters:
val – New cap for ranges.
- Returns:
This RangeSet after removal.
-
inline RangeSet &Remove(range_t rm_range)
Remove a whole Range from this RangeSet.
- Parameters:
rm_range – Range to remove
- Returns:
This RangeSet after removal.
-
inline RangeSet &Remove(const this_t &in_set)
Remove all ranges in an entire range set from this one.
Note
Can be optimized to handle big sets more efficiently!
- Parameters:
in_set – Range set to remove.
- Returns:
This RangeSet after removal.
-
inline RangeSet &KeepOnly(const this_t &in_set)
Remove everything outside of the provided set of ranges.
-
inline this_t CalcInverse() const
Calculate the inverted range set, swapping included and excluded values.
- Returns:
The inverted RangeSet.
-
inline explicit operator bool() const
-
inline bool OK() const
Check for internal errors in this RangeSet.
-
RangeSet() = default