Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(107)

Unified Diff: util/numeric/checked_range.h

Issue 1372183002: win: Add memory map range intersection helper (Closed) Base URL: https://chromium.googlesource.com/crashpad/crashpad@master
Patch Set: . Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | util/numeric/checked_range_test.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: util/numeric/checked_range.h
diff --git a/util/numeric/checked_range.h b/util/numeric/checked_range.h
index e1a2abf8195716f7554c265341e7eeea9a215cae..972a038e8da312dd5ae9679f1623fee09260ca10 100644
--- a/util/numeric/checked_range.h
+++ b/util/numeric/checked_range.h
@@ -104,11 +104,31 @@ class CheckedRange {
return that.base() >= base() && that.end() <= end();
}
+ //! \brief Returns whether the range overlaps another range.
+ //!
+ //! \param[in] that The (possibly) overlapping range.
+ //!
+ //! \return `true` if `this` range, the first range, overlaps \a that,
+ //! the provided range. `false` otherwise.
+ //!
+ //! Ranges are considered to be closed-open [base, end) for this test. Zero
+ //! length ranges are never considered to overlap another range.
+ //!
+ //! This method must only be called if IsValid() would return `true` for both
+ //! CheckedRange objects involved.
+ bool OverlapsRange(const CheckedRange<ValueType, SizeType>& that) const {
+ DCHECK(IsValid());
+ DCHECK(that.IsValid());
+
+ if (size() == 0 || that.size() == 0)
+ return false;
+
+ return base() < that.end() && that.base() < end();
+ }
+
private:
ValueType base_;
SizeType size_;
-
- DISALLOW_COPY_AND_ASSIGN(CheckedRange);
};
} // namespace crashpad
« no previous file with comments | « no previous file | util/numeric/checked_range_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698