| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 MOJO_PUBLIC_CPP_BINDINGS_TESTS_RECT_BLINK_H_ | 5 #ifndef MOJO_PUBLIC_CPP_BINDINGS_TESTS_RECT_BLINK_H_ |
| 6 #define MOJO_PUBLIC_CPP_BINDINGS_TESTS_RECT_BLINK_H_ | 6 #define MOJO_PUBLIC_CPP_BINDINGS_TESTS_RECT_BLINK_H_ |
| 7 | 7 |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 | 9 |
| 10 namespace mojo { | 10 namespace mojo { |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 } | 44 } |
| 45 | 45 |
| 46 int height() const { return height_; } | 46 int height() const { return height_; } |
| 47 void setHeight(int height) { | 47 void setHeight(int height) { |
| 48 DCHECK_GE(height, 0); | 48 DCHECK_GE(height, 0); |
| 49 height_ = height; | 49 height_ = height; |
| 50 } | 50 } |
| 51 | 51 |
| 52 int computeArea() const { return width_ * height_; } | 52 int computeArea() const { return width_ * height_; } |
| 53 | 53 |
| 54 bool operator==(const RectBlink& other) const { |
| 55 return (x() == other.x() && y() == other.y() && width() == other.width() && |
| 56 height() == other.height()); |
| 57 } |
| 58 bool operator!=(const RectBlink& other) const { return !(*this == other); } |
| 59 |
| 54 private: | 60 private: |
| 55 int x_ = 0; | 61 int x_ = 0; |
| 56 int y_ = 0; | 62 int y_ = 0; |
| 57 int width_ = 0; | 63 int width_ = 0; |
| 58 int height_ = 0; | 64 int height_ = 0; |
| 59 }; | 65 }; |
| 60 | 66 |
| 61 } // namespace test | 67 } // namespace test |
| 62 } // namespace mojo | 68 } // namespace mojo |
| 63 | 69 |
| 70 namespace std { |
| 71 |
| 72 template <> |
| 73 struct hash<mojo::test::RectBlink> { |
| 74 size_t operator()(const mojo::test::RectBlink& value) { |
| 75 // Terrible hash function: |
| 76 return (std::hash<int>()(value.x()) ^ std::hash<int>()(value.y()) ^ |
| 77 std::hash<int>()(value.width()) ^ std::hash<int>()(value.height())); |
| 78 } |
| 79 }; |
| 80 |
| 81 } // namespace std |
| 82 |
| 64 #endif // MOJO_PUBLIC_CPP_BINDINGS_TESTS_RECT_BLINK_H_ | 83 #endif // MOJO_PUBLIC_CPP_BINDINGS_TESTS_RECT_BLINK_H_ |
| OLD | NEW |