From 597daefeb6ed9aae91289b05cf231e8857705f57 Mon Sep 17 00:00:00 2001 From: Matthew Fernandez Date: Fri, 7 May 2021 20:42:36 -0700 Subject: [PATCH] manage graph collection in VPSC::constraintGraphIsCyclic with smart pointers Removes some manual memory management. --- lib/vpsc/solve_VPSC.cpp | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/lib/vpsc/solve_VPSC.cpp b/lib/vpsc/solve_VPSC.cpp index f683de8e0..80e73dfd4 100644 --- a/lib/vpsc/solve_VPSC.cpp +++ b/lib/vpsc/solve_VPSC.cpp @@ -22,6 +22,7 @@ #include #include #include +#include #include #include using std::ios; @@ -306,11 +307,10 @@ struct node { // useful in debugging - cycles would be BAD bool VPSC::constraintGraphIsCyclic(const unsigned n, Variable *vs[]) { map varmap; - vector graph; + vector> graph; for(unsigned i=0;iin) { @@ -325,9 +325,9 @@ bool VPSC::constraintGraphIsCyclic(const unsigned n, Variable *vs[]) { } while(!graph.empty()) { node *u=nullptr; - vector::iterator i=graph.begin(); + vector>::iterator i=graph.begin(); for(;i!=graph.end();i++) { - u=*i; + u=(*i).get(); if(u->in.empty()) { break; } @@ -340,12 +340,8 @@ bool VPSC::constraintGraphIsCyclic(const unsigned n, Variable *vs[]) { for(node *v : u->out) { v->in.erase(u); } - delete u; } } - for(unsigned i=0; i