Material PDF: Restore animated entry and exit of viewer toolbars
[chromium-blink-merge.git] / tools / gn / deps_iterator.cc
blob8bbb760e59a243f5ad7194933f58eb1ed454e182
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "tools/gn/deps_iterator.h"
7 #include "tools/gn/target.h"
9 DepsIterator::DepsIterator() : current_index_(0) {
10 vect_stack_[0] = nullptr;
11 vect_stack_[1] = nullptr;
12 vect_stack_[2] = nullptr;
15 DepsIterator::DepsIterator(const LabelTargetVector* a,
16 const LabelTargetVector* b,
17 const LabelTargetVector* c)
18 : current_index_(0) {
19 vect_stack_[0] = a;
20 vect_stack_[1] = b;
21 vect_stack_[2] = c;
23 if (vect_stack_[0] && vect_stack_[0]->empty())
24 operator++();
27 // Advance to the next position. This assumes there are more vectors.
29 // For internal use, this function tolerates an initial index equal to the
30 // length of the current vector. In this case, it will advance to the next
31 // one.
32 DepsIterator& DepsIterator::operator++() {
33 DCHECK(vect_stack_[0]);
35 current_index_++;
36 if (current_index_ >= vect_stack_[0]->size()) {
37 // Advance to next vect. Shift the elements left by one.
38 vect_stack_[0] = vect_stack_[1];
39 vect_stack_[1] = vect_stack_[2];
40 vect_stack_[2] = nullptr;
42 current_index_ = 0;
44 if (vect_stack_[0] && vect_stack_[0]->empty())
45 operator++();
47 return *this;
50 DepsIteratorRange::DepsIteratorRange(const DepsIterator& b)
51 : begin_(b),
52 end_() {
55 DepsIteratorRange::~DepsIteratorRange() {