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

Side by Side 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, 2 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 unified diff | Download patch
« no previous file with comments | « no previous file | util/numeric/checked_range_test.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Crashpad Authors. All rights reserved. 1 // Copyright 2014 The Crashpad Authors. All rights reserved.
2 // 2 //
3 // Licensed under the Apache License, Version 2.0 (the "License"); 3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License. 4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at 5 // You may obtain a copy of the License at
6 // 6 //
7 // http://www.apache.org/licenses/LICENSE-2.0 7 // http://www.apache.org/licenses/LICENSE-2.0
8 // 8 //
9 // Unless required by applicable law or agreed to in writing, software 9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS, 10 // distributed under the License is distributed on an "AS IS" BASIS,
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 //! 97 //!
98 //! This method must only be called if IsValid() would return `true` for both 98 //! This method must only be called if IsValid() would return `true` for both
99 //! CheckedRange objects involved. 99 //! CheckedRange objects involved.
100 bool ContainsRange(const CheckedRange<ValueType, SizeType>& that) const { 100 bool ContainsRange(const CheckedRange<ValueType, SizeType>& that) const {
101 DCHECK(IsValid()); 101 DCHECK(IsValid());
102 DCHECK(that.IsValid()); 102 DCHECK(that.IsValid());
103 103
104 return that.base() >= base() && that.end() <= end(); 104 return that.base() >= base() && that.end() <= end();
105 } 105 }
106 106
107 //! \brief Returns whether the range overlaps another range.
108 //!
109 //! \param[in] that The (possibly) overlapping range.
110 //!
111 //! \return `true` if `this` range, the first range, overlaps \a that,
112 //! the provided range. `false` otherwise.
113 //!
114 //! Ranges are considered to be closed-open [base, end) for this test. Zero
115 //! length ranges are never considered to overlap another range.
116 //!
117 //! This method must only be called if IsValid() would return `true` for both
118 //! CheckedRange objects involved.
119 bool OverlapsRange(const CheckedRange<ValueType, SizeType>& that) const {
120 DCHECK(IsValid());
121 DCHECK(that.IsValid());
122
123 if (size() == 0 || that.size() == 0)
124 return false;
125
126 return base() < that.end() && that.base() < end();
127 }
128
107 private: 129 private:
108 ValueType base_; 130 ValueType base_;
109 SizeType size_; 131 SizeType size_;
110
111 DISALLOW_COPY_AND_ASSIGN(CheckedRange);
112 }; 132 };
113 133
114 } // namespace crashpad 134 } // namespace crashpad
115 135
116 #endif // CRASHPAD_UTIL_NUMERIC_CHECKED_RANGE_H_ 136 #endif // CRASHPAD_UTIL_NUMERIC_CHECKED_RANGE_H_
OLDNEW
« 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