14 #ifndef UNIQUERANGESET_H 15 #define UNIQUERANGESET_H 38 class UniqueRangeSet :
public std::set<util::Range<T> > {
47 {
for(
auto const& r : in)
emplace(r._window.first,r._window.second); }
52 if(!(this->size()))
throw std::runtime_error(
"Nothing in the set!");
53 return (*(this->
begin()))._window.first;
59 if(!(this->size()))
throw std::runtime_error(
"Nothing in the set!");
60 return (*(this->rbegin()))._window.second;
72 auto start_iter = std::lower_bound(this->
begin(),this->
end(),start);
73 auto end_iter = std::lower_bound(this->
begin(),this->
end(),end);
76 if(start < (*start_iter)._window.first) res.emplace(start,(*start_iter)._window.first);
78 auto iter = start_iter;
80 while(iter != this->
end()) {
81 if(iter != start_iter)
82 res.emplace(tmp_end,(*iter)._window.first);
83 tmp_end = (*iter)._window.second;
84 if(iter == end_iter)
break;
90 res.emplace(tmp_end,end);
98 auto res = std::set<util::Range<T> >
::emplace(start,end);
99 if(res.second)
return 0;
101 auto& iter = res.first;
104 while(iter != this->
end()) {
105 tmp_a.
Merge((*iter));
107 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.
Namespace for general, non-LArSoft-specific utilities.
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.
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.
std::vector< evd::details::RawDigitInfo_t >::const_iterator begin(RawDigitCacheDataClass const &cache)
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!)
std::set of util::Range, which does not allow any overlap in contained element. std::set<Range> w/ mo...
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.
std::vector< evd::details::RawDigitInfo_t >::const_iterator end(RawDigitCacheDataClass const &cache)