From 18dc8b174995d6d37c6cdfc66cb1ba141729b2ed Mon Sep 17 00:00:00 2001 From: Carlo Zancanaro Date: Tue, 10 Jul 2012 16:42:34 +1000 Subject: Modify MaxStrategy to print itself better. --- impl/MaxStrategy.hpp | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) (limited to 'impl/MaxStrategy.hpp') 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 #include "Expression.hpp" #include "EquationSystem.hpp" #include "IdSet.hpp" @@ -14,7 +15,8 @@ struct MaxStrategy { template struct ConcreteMaxStrategy : public MaxStrategy { ConcreteMaxStrategy(const EquationSystem& system) - : _strategy(system.maxExpressionCount(), 0) { + : _system(system), + _strategy(system.maxExpressionCount(), 0) { } unsigned int get(const MaxExpression& e) const { @@ -26,11 +28,26 @@ struct ConcreteMaxStrategy : public MaxStrategy { } 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& _system; IdMap,unsigned int> _strategy; }; +template +std::ostream& operator<<(std::ostream& cout, const ConcreteMaxStrategy& strat) { + strat.print(cout); + return cout; +} + #endif -- cgit v1.2.3