From 299f7a3ac5118aa0f009aebb4d1792860e610d29 Mon Sep 17 00:00:00 2001 From: Brian Norris Date: Wed, 12 Dec 2012 17:57:28 -0800 Subject: [PATCH] nodestack: make 'iter' signed iter will need to be negative when we allow the NodeStack to be empty. --- nodestack.cc | 6 +++--- nodestack.h | 9 ++++++++- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/nodestack.cc b/nodestack.cc index d81dd0c..091a0f7 100644 --- a/nodestack.cc +++ b/nodestack.cc @@ -513,7 +513,7 @@ void NodeStack::print() const model_print("............................................\n"); model_print("NodeStack printing node_list:\n"); for (unsigned int it = 0; it < node_list.size(); it++) { - if (it == this->iter) + if ((int)it == this->iter) model_print("vvv following action is the current iterator vvv\n"); node_list[it]->print(); } @@ -528,7 +528,7 @@ ModelAction * NodeStack::explore_action(ModelAction *act, enabled_type_t *is_ena ASSERT(!node_list.empty()); - if ((iter + 1) < node_list.size()) { + if ((iter + 1) < (int)node_list.size()) { iter++; return node_list[iter]->get_action(); } @@ -536,7 +536,7 @@ ModelAction * NodeStack::explore_action(ModelAction *act, enabled_type_t *is_ena /* Record action */ get_head()->explore_child(act, is_enabled); Node *prevfairness = NULL; - if (model->params.fairwindow != 0 && iter > model->params.fairwindow) + if (model->params.fairwindow != 0 && iter > (int)model->params.fairwindow) prevfairness = node_list[iter - model->params.fairwindow]; node_list.push_back(new Node(act, get_head(), model->get_num_threads(), prevfairness)); total_nodes++; diff --git a/nodestack.h b/nodestack.h index 90d84bd..4db15fc 100644 --- a/nodestack.h +++ b/nodestack.h @@ -166,7 +166,14 @@ public: MEMALLOC private: node_list_t node_list; - unsigned int iter; + + /** + * @brief the index position of the current head Node + * + * This index is relative to node_list. The index should point to the + * current head Node. + */ + int iter; int total_nodes; }; -- 2.34.1