From 5c68a07738dbfddc813ef4ed57e730b96fcae9a9 Mon Sep 17 00:00:00 2001 From: Duy-Nguyen Ta Date: Thu, 21 Oct 2010 23:02:40 +0000 Subject: [PATCH] Fix bug in Ordering code where it keeps on increasing nVar even the insert is not successful. --- nonlinear/Ordering.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/nonlinear/Ordering.h b/nonlinear/Ordering.h index e6a8c15ef..92efb0b75 100644 --- a/nonlinear/Ordering.h +++ b/nonlinear/Ordering.h @@ -76,7 +76,8 @@ public: iterator insert(const Symbol& key, Index order) { return insert(std::make_pair(key,order)); } std::pair tryInsert(const value_type& key_order) { std::pair it_ok(order_.insert(key_order)); - if(key_order.second+1 > nVars_) nVars_ = key_order.second+1; + if(it_ok.second == true && key_order.second+1 > nVars_) + nVars_ = key_order.second+1; return it_ok; } std::pair tryInsert(const Symbol& key, Index order) { return tryInsert(std::make_pair(key,order)); }