OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 #include "cc/base/spiral_iterator.h" | 5 #include "cc/base/spiral_iterator.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 namespace cc { | 9 namespace cc { |
10 | 10 |
(...skipping 23 matching lines...) Expand all Loading... |
34 current_step_ = horizontal_step_count_ - 1; | 34 current_step_ = horizontal_step_count_ - 1; |
35 | 35 |
36 index_x_ = around_index_rect_.right(); | 36 index_x_ = around_index_rect_.right(); |
37 index_y_ = around_index_rect_.bottom(); | 37 index_y_ = around_index_rect_.bottom(); |
38 | 38 |
39 // The current index is the bottom right of the around rect, which is also | 39 // The current index is the bottom right of the around rect, which is also |
40 // ignored. So we have to advance. | 40 // ignored. So we have to advance. |
41 ++(*this); | 41 ++(*this); |
42 } | 42 } |
43 | 43 |
| 44 SpiralIterator::SpiralIterator(const SpiralIterator& other) = default; |
| 45 |
| 46 SpiralIterator::SpiralIterator(SpiralIterator&& other) = default; |
| 47 |
| 48 SpiralIterator::~SpiralIterator() = default; |
| 49 |
| 50 SpiralIterator& SpiralIterator::operator=(const SpiralIterator& other) = |
| 51 default; |
| 52 |
| 53 SpiralIterator& SpiralIterator::operator=(SpiralIterator&& other) = default; |
| 54 |
44 SpiralIterator::operator bool() const { | 55 SpiralIterator::operator bool() const { |
45 return index_x_ != -1 && index_y_ != -1; | 56 return index_x_ != -1 && index_y_ != -1; |
46 } | 57 } |
47 | 58 |
48 SpiralIterator& SpiralIterator::operator++() { | 59 SpiralIterator& SpiralIterator::operator++() { |
49 int cannot_hit_consider_count = 0; | 60 int cannot_hit_consider_count = 0; |
50 while (cannot_hit_consider_count < 4) { | 61 while (cannot_hit_consider_count < 4) { |
51 if (needs_direction_switch()) | 62 if (needs_direction_switch()) |
52 switch_direction(); | 63 switch_direction(); |
53 | 64 |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
153 current_step_ = 0; | 164 current_step_ = 0; |
154 direction_ = static_cast<Direction>((direction_ + 1) % 4); | 165 direction_ = static_cast<Direction>((direction_ + 1) % 4); |
155 | 166 |
156 if (direction_ == RIGHT || direction_ == LEFT) { | 167 if (direction_ == RIGHT || direction_ == LEFT) { |
157 ++vertical_step_count_; | 168 ++vertical_step_count_; |
158 ++horizontal_step_count_; | 169 ++horizontal_step_count_; |
159 } | 170 } |
160 } | 171 } |
161 | 172 |
162 } // namespace cc | 173 } // namespace cc |
OLD | NEW |