14 #ifndef UNIQUERANGESET_H
15 #define UNIQUERANGESET_H
36 class UniqueRangeSet :
public std::set<util::Range<T> > {
45 {
for(
auto const&
r : in)
emplace(
r._window.first,
r._window.second); }
50 if(!(this->
size()))
throw std::runtime_error(
"Nothing in the set!");
51 return (*(this->
begin()))._window.first;
57 if(!(this->
size()))
throw std::runtime_error(
"Nothing in the set!");
58 return (*(this->rbegin()))._window.second;
70 auto start_iter = std::lower_bound(this->
begin(),this->
end(),start);
71 auto end_iter = std::lower_bound(this->
begin(),this->
end(),end);
74 if(start < (*start_iter)._window.first) res.emplace(start,(*start_iter)._window.first);
76 auto iter = start_iter;
78 while(iter != this->
end()) {
79 if(iter != start_iter)
80 res.emplace(tmp_end,(*iter)._window.first);
81 tmp_end = (*iter)._window.second;
82 if(iter == end_iter)
break;
88 res.emplace(tmp_end,end);
96 auto res = std::set<util::Range<T> >
::emplace(start,end);
97 if(res.second)
return 0;
99 auto& iter = res.first;
102 while(iter != this->
end()) {
103 tmp_a.
Merge((*iter));
105 iter = this->find(tmp_a);
size_t insert(const Range< T > &a)
Modified insert that merges overlapping range. Return = # merged range.
void Merge(const Range &a)
Merge two util::Range into 1.
UniqueRangeSet()
default ctor
void Merge(const UniqueRangeSet< T > &in)
Merge two UniqueRangeSet<T>
~UniqueRangeSet()
default dtor
const T & Start() const
Very first "start" of all contained range.
decltype(auto) constexpr end(T &&obj)
ADL-aware version of std::end.
decltype(auto) constexpr size(T &&obj)
ADL-aware version of std::size.
Class def header for a class Range.
size_t emplace(const T &start, const T &end)
Modified emplace that merges overlapping range. Return = # merged range.
UniqueRangeSet< T > Exclusive(const T start, const T end) const
std::pair< T, T > _window
Protected to avoid user's illegal modification on first/second (sorry users!)
if &&[-z"$BASH_VERSION"] then echo Attempting to switch to bash bash shellSwitch exit fi &&["$1"= 'shellSwitch'] shift declare a IncludeDirectives for Dir in
std::set of util::Range, which does not allow any overlap in contained element. std::set<Range> w/ modi...
represents a "Range" w/ notion of ordering. A range is defined by a pair of "start" and "end" values...
const T & End() const
Very last "end" of all contained range.
decltype(auto) constexpr begin(T &&obj)
ADL-aware version of std::begin.