diff options
-rw-r--r-- | src/state.cc | 9 | ||||
-rw-r--r-- | src/state.h | 4 |
2 files changed, 7 insertions, 6 deletions
diff --git a/src/state.cc b/src/state.cc index a70f211..d539e7b 100644 --- a/src/state.cc +++ b/src/state.cc @@ -159,11 +159,12 @@ bool State::AddDefault(StringPiece path, string* err) { return true; } -vector<Node*> State::RootNodes(string* err) { +vector<Node*> State::RootNodes(string* err) const { vector<Node*> root_nodes; // Search for nodes with no output. - for (vector<Edge*>::iterator e = edges_.begin(); e != edges_.end(); ++e) { - for (vector<Node*>::iterator out = (*e)->outputs_.begin(); + for (vector<Edge*>::const_iterator e = edges_.begin(); + e != edges_.end(); ++e) { + for (vector<Node*>::const_iterator out = (*e)->outputs_.begin(); out != (*e)->outputs_.end(); ++out) { if ((*out)->out_edges().empty()) root_nodes.push_back(*out); @@ -176,7 +177,7 @@ vector<Node*> State::RootNodes(string* err) { return root_nodes; } -vector<Node*> State::DefaultNodes(string* err) { +vector<Node*> State::DefaultNodes(string* err) const { return defaults_.empty() ? RootNodes(err) : defaults_; } diff --git a/src/state.h b/src/state.h index d7987ba..b530207 100644 --- a/src/state.h +++ b/src/state.h @@ -110,8 +110,8 @@ struct State { /// @return the root node(s) of the graph. (Root nodes have no output edges). /// @param error where to write the error message if somethings went wrong. - vector<Node*> RootNodes(string* error); - vector<Node*> DefaultNodes(string* error); + vector<Node*> RootNodes(string* error) const; + vector<Node*> DefaultNodes(string* error) const; /// Mapping of path -> Node. typedef ExternalStringHashMap<Node*>::Type Paths; |