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
)
23 if (vect_stack_
[0] && vect_stack_
[0]->empty())
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
32 DepsIterator
& DepsIterator::operator++() {
33 DCHECK(vect_stack_
[0]);
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;
44 if (vect_stack_
[0] && vect_stack_
[0]->empty())
50 DepsIteratorRange::DepsIteratorRange(const DepsIterator
& b
)
55 DepsIteratorRange::~DepsIteratorRange() {