#ifndef EQUATIONSYSTEM_H #define EQUATIONSYSTEM_H #include "Equation.h" #include template struct EquationSystem { bool add(Equation e) { for (iterator it = equations.begin(); it != equations.end(); ++it) { if ((*it).var().name() == e.var().name()) { return false; } } this->equations.push_back(e); return true; } std::map solve(std::map start) { std::map result = start; std::map comparison; do { comparison = result; for (iterator it = equations.begin(); it != equations.end(); ++it) { result = it->solve(result); } } while (comparison != result); return result; } private: typedef typename std::list< Equation >::iterator iterator; std::list< Equation > equations; }; #endif