Add RangeSet::lebesgue_sum

This commit is contained in:
Vinnie Falco
2015-05-11 18:36:23 -07:00
parent f030aab759
commit d5a6313c71
2 changed files with 13 additions and 0 deletions

View File

@@ -57,6 +57,10 @@ public:
std::string toString () const;
/** Returns the sum of the Lebesgue measures of all sub-ranges. */
std::size_t
lebesgue_sum() const;
/** Check invariants of the data.
This is for diagnostics, and does nothing in release builds.

View File

@@ -235,6 +235,15 @@ void RangeSet::simplify ()
}
}
std::size_t
RangeSet::lebesgue_sum() const
{
std::size_t sum = mRanges.size();
for (auto const& e : mRanges)
sum += e.second - e.first;
return sum;
}
void RangeSet::checkInternalConsistency () const noexcept
{
#ifndef NDEBUG