diff options
-rw-r--r-- | impl/MaxStrategy.hpp | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/impl/MaxStrategy.hpp b/impl/MaxStrategy.hpp index 3005ee2..21a6420 100644 --- a/impl/MaxStrategy.hpp +++ b/impl/MaxStrategy.hpp @@ -1,6 +1,7 @@ #ifndef MAX_EXPRESSION_HPP #define MAX_EXPRESSION_HPP +#include <ostream> #include "Expression.hpp" #include "EquationSystem.hpp" #include "IdSet.hpp" @@ -14,7 +15,8 @@ struct MaxStrategy { template<typename Domain> struct ConcreteMaxStrategy : public MaxStrategy<Domain> { ConcreteMaxStrategy(const EquationSystem<Domain>& system) - : _strategy(system.maxExpressionCount(), 0) { + : _system(system), + _strategy(system.maxExpressionCount(), 0) { } unsigned int get(const MaxExpression<Domain>& e) const { @@ -26,11 +28,26 @@ struct ConcreteMaxStrategy : public MaxStrategy<Domain> { } void print(std::ostream& cout) const { - cout << _strategy << std::endl; + for (unsigned int i = 0, length = _system.maxExpressionCount(); + i < length; + ++i) { + auto expr = _system.maxExpression(i); + unsigned int subExpression = get(expr); + cout << expr + << " --[" << subExpression << "]-> " + << *expr.arguments()[subExpression] << std::endl; + } } private: + const EquationSystem<Domain>& _system; IdMap<MaxExpression<Domain>,unsigned int> _strategy; }; +template<typename Domain> +std::ostream& operator<<(std::ostream& cout, const ConcreteMaxStrategy<Domain>& strat) { + strat.print(cout); + return cout; +} + #endif |