| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef MEDIA_BASE_RANGES_H_ | 5 #ifndef MEDIA_BASE_RANGES_H_ |
| 6 #define MEDIA_BASE_RANGES_H_ | 6 #define MEDIA_BASE_RANGES_H_ |
| 7 | 7 |
| 8 #include <algorithm> | 8 #include <algorithm> |
| 9 #include <ostream> | 9 #include <ostream> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 // Allow copy & assign. | 25 // Allow copy & assign. |
| 26 | 26 |
| 27 // Add (start,end) to this object, coallescing overlaps as appropriate. | 27 // Add (start,end) to this object, coallescing overlaps as appropriate. |
| 28 // Returns the number of stored ranges, post coallescing. | 28 // Returns the number of stored ranges, post coallescing. |
| 29 size_t Add(T start, T end); | 29 size_t Add(T start, T end); |
| 30 | 30 |
| 31 // Return the number of disjoint ranges. | 31 // Return the number of disjoint ranges. |
| 32 size_t size() const; | 32 size_t size() const; |
| 33 | 33 |
| 34 // Return the "i"'th range's start & end (0-based). | 34 // Return the "i"'th range's start & end (0-based). |
| 35 T start(int i) const; | 35 T start(size_t i) const; |
| 36 T end(int i) const; | 36 T end(size_t i) const; |
| 37 | 37 |
| 38 // Clear all ranges. | 38 // Clear all ranges. |
| 39 void clear(); | 39 void clear(); |
| 40 | 40 |
| 41 // Computes the intersection between this range and |other|. | 41 // Computes the intersection between this range and |other|. |
| 42 Ranges<T> IntersectionWith(const Ranges<T>& other) const; | 42 Ranges<T> IntersectionWith(const Ranges<T>& other) const; |
| 43 | 43 |
| 44 private: | 44 private: |
| 45 // Wrapper around DCHECK_LT allowing comparisons of operator<<'able T's. | 45 // Wrapper around DCHECK_LT allowing comparisons of operator<<'able T's. |
| 46 void DCheckLT(const T& lhs, const T& rhs) const; | 46 void DCheckLT(const T& lhs, const T& rhs) const; |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 112 void Ranges<T>::DCheckLT(const T& lhs, const T& rhs) const { | 112 void Ranges<T>::DCheckLT(const T& lhs, const T& rhs) const { |
| 113 DCHECK_LT(lhs, rhs); | 113 DCHECK_LT(lhs, rhs); |
| 114 } | 114 } |
| 115 | 115 |
| 116 template<class T> | 116 template<class T> |
| 117 size_t Ranges<T>::size() const { | 117 size_t Ranges<T>::size() const { |
| 118 return ranges_.size(); | 118 return ranges_.size(); |
| 119 } | 119 } |
| 120 | 120 |
| 121 template<class T> | 121 template<class T> |
| 122 T Ranges<T>::start(int i) const { | 122 T Ranges<T>::start(size_t i) const { |
| 123 return ranges_[i].first; | 123 return ranges_[i].first; |
| 124 } | 124 } |
| 125 | 125 |
| 126 template<class T> | 126 template<class T> |
| 127 T Ranges<T>::end(int i) const { | 127 T Ranges<T>::end(size_t i) const { |
| 128 return ranges_[i].second; | 128 return ranges_[i].second; |
| 129 } | 129 } |
| 130 | 130 |
| 131 template<class T> | 131 template<class T> |
| 132 void Ranges<T>::clear() { | 132 void Ranges<T>::clear() { |
| 133 ranges_.clear(); | 133 ranges_.clear(); |
| 134 } | 134 } |
| 135 | 135 |
| 136 template<class T> | 136 template<class T> |
| 137 Ranges<T> Ranges<T>::IntersectionWith(const Ranges<T>& other) const { | 137 Ranges<T> Ranges<T>::IntersectionWith(const Ranges<T>& other) const { |
| (...skipping 15 matching lines...) Expand all Loading... |
| 153 else | 153 else |
| 154 ++j; | 154 ++j; |
| 155 } | 155 } |
| 156 | 156 |
| 157 return result; | 157 return result; |
| 158 } | 158 } |
| 159 | 159 |
| 160 } // namespace media | 160 } // namespace media |
| 161 | 161 |
| 162 #endif // MEDIA_BASE_RANGES_H_ | 162 #endif // MEDIA_BASE_RANGES_H_ |
| OLD | NEW |