summaryrefslogtreecommitdiff
path: root/impl
diff options
context:
space:
mode:
authorCarlo Zancanaro <carlo@pc-4w14-0.cs.usyd.edu.au>2012-07-10 16:42:34 +1000
committerCarlo Zancanaro <carlo@pc-4w14-0.cs.usyd.edu.au>2012-07-10 16:42:34 +1000
commit18dc8b174995d6d37c6cdfc66cb1ba141729b2ed (patch)
tree12b570a0600e772603e3c02f8cdc03b2955312ce /impl
parentef4a319984d22b88a9024ff523700d657621124d (diff)
Modify MaxStrategy to print itself better.
Diffstat (limited to 'impl')
-rw-r--r--impl/MaxStrategy.hpp21
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