forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdeps_iterator.cc
56 lines (45 loc) · 1.46 KB
/
deps_iterator.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "tools/gn/deps_iterator.h"
#include "tools/gn/target.h"
DepsIterator::DepsIterator() : current_index_(0) {
vect_stack_[0] = nullptr;
vect_stack_[1] = nullptr;
vect_stack_[2] = nullptr;
}
DepsIterator::DepsIterator(const LabelTargetVector* a,
const LabelTargetVector* b,
const LabelTargetVector* c)
: current_index_(0) {
vect_stack_[0] = a;
vect_stack_[1] = b;
vect_stack_[2] = c;
if (vect_stack_[0] && vect_stack_[0]->empty())
operator++();
}
// Advance to the next position. This assumes there are more vectors.
//
// For internal use, this function tolerates an initial index equal to the
// length of the current vector. In this case, it will advance to the next
// one.
DepsIterator& DepsIterator::operator++() {
DCHECK(vect_stack_[0]);
current_index_++;
if (current_index_ >= vect_stack_[0]->size()) {
// Advance to next vect. Shift the elements left by one.
vect_stack_[0] = vect_stack_[1];
vect_stack_[1] = vect_stack_[2];
vect_stack_[2] = nullptr;
current_index_ = 0;
if (vect_stack_[0] && vect_stack_[0]->empty())
operator++();
}
return *this;
}
DepsIteratorRange::DepsIteratorRange(const DepsIterator& b)
: begin_(b),
end_() {
}
DepsIteratorRange::~DepsIteratorRange() {
}