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 UI_BASE_RANGE_RANGE_H_ | 5 #ifndef UI_BASE_RANGE_RANGE_H_ |
6 #define UI_BASE_RANGE_RANGE_H_ | 6 #define UI_BASE_RANGE_RANGE_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 | 58 |
59 // Getters and setters. | 59 // Getters and setters. |
60 size_t start() const { return start_; } | 60 size_t start() const { return start_; } |
61 void set_start(size_t start) { start_ = start; } | 61 void set_start(size_t start) { start_ = start; } |
62 | 62 |
63 size_t end() const { return end_; } | 63 size_t end() const { return end_; } |
64 void set_end(size_t end) { end_ = end; } | 64 void set_end(size_t end) { end_ = end; } |
65 | 65 |
66 // Returns the absolute value of the length. | 66 // Returns the absolute value of the length. |
67 size_t length() const { | 67 size_t length() const { |
68 int length = end() - start(); | 68 ptrdiff_t length = end() - start(); |
69 return length >= 0 ? length : -length; | 69 return length >= 0 ? length : -length; |
70 } | 70 } |
71 | 71 |
72 bool is_reversed() const { return start() > end(); } | 72 bool is_reversed() const { return start() > end(); } |
73 bool is_empty() const { return start() == end(); } | 73 bool is_empty() const { return start() == end(); } |
74 | 74 |
75 // Returns the minimum and maximum values. | 75 // Returns the minimum and maximum values. |
76 size_t GetMin() const; | 76 size_t GetMin() const; |
77 size_t GetMax() const; | 77 size_t GetMax() const; |
78 | 78 |
(...skipping 26 matching lines...) Expand all Loading... |
105 std::string ToString() const; | 105 std::string ToString() const; |
106 | 106 |
107 private: | 107 private: |
108 size_t start_; | 108 size_t start_; |
109 size_t end_; | 109 size_t end_; |
110 }; | 110 }; |
111 | 111 |
112 } // namespace ui | 112 } // namespace ui |
113 | 113 |
114 #endif // UI_BASE_RANGE_RANGE_H_ | 114 #endif // UI_BASE_RANGE_RANGE_H_ |
OLD | NEW |