diff --git a/src/ripple/basics/RangeSet.h b/src/ripple/basics/RangeSet.h index 903e6a1e4..c66a945fe 100644 --- a/src/ripple/basics/RangeSet.h +++ b/src/ripple/basics/RangeSet.h @@ -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. diff --git a/src/ripple/basics/impl/RangeSet.cpp b/src/ripple/basics/impl/RangeSet.cpp index 362545c0e..0bfc627fd 100644 --- a/src/ripple/basics/impl/RangeSet.cpp +++ b/src/ripple/basics/impl/RangeSet.cpp @@ -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