Removing uses of X11 native key events.
[chromium-blink-merge.git] / tools / gn / deps_iterator.cc
blob1f964f38461af15f1caf71dfada67cb4d42158bc
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(const Target* t) : current_index_(0) {
10 vect_stack_[0] = &t->public_deps();
11 vect_stack_[1] = &t->private_deps();
12 vect_stack_[2] = &t->data_deps();
14 if (vect_stack_[0]->empty())
15 Advance();
18 // Iterate over the public and private linked deps, but not the data deps.
19 DepsIterator::DepsIterator(const Target* t, LinkedOnly) : current_index_(0) {
20 vect_stack_[0] = &t->public_deps();
21 vect_stack_[1] = &t->private_deps();
22 vect_stack_[2] = NULL;
24 if (vect_stack_[0]->empty())
25 Advance();
28 // Advance to the next position. This assumes there are more vectors.
30 // For internal use, this function tolerates an initial index equal to the
31 // length of the current vector. In this case, it will advance to the next
32 // one.
33 void DepsIterator::Advance() {
34 DCHECK(vect_stack_[0]);
36 current_index_++;
37 if (current_index_ >= vect_stack_[0]->size()) {
38 // Advance to next vect. Shift the elements left by one.
39 vect_stack_[0] = vect_stack_[1];
40 vect_stack_[1] = vect_stack_[2];
41 vect_stack_[2] = NULL;
43 current_index_ = 0;
45 if (vect_stack_[0] && vect_stack_[0]->empty())
46 Advance();