diff options
author | Carlo Zancanaro <carlo@pc-4w14-0.cs.usyd.edu.au> | 2012-05-25 13:24:37 +1000 |
---|---|---|
committer | Carlo Zancanaro <carlo@pc-4w14-0.cs.usyd.edu.au> | 2012-05-25 13:24:37 +1000 |
commit | 61f90f14af8796bbed074538882e76f1e1bf3333 (patch) | |
tree | 5d1dc744b47817a39b905418b1fc76bb828cea4a /impl/MaxStrategy.hpp | |
parent | ee8547cf3c89c51ff10603814e6f745466bc4c79 (diff) |
Try to make some more modular Fixpoint algorithms.
Diffstat (limited to 'impl/MaxStrategy.hpp')
-rw-r--r-- | impl/MaxStrategy.hpp | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/impl/MaxStrategy.hpp b/impl/MaxStrategy.hpp index f4e4055..a1c50d8 100644 --- a/impl/MaxStrategy.hpp +++ b/impl/MaxStrategy.hpp @@ -23,6 +23,10 @@ struct MaxStrategy { } } + virtual ~MaxStrategy() { + delete[] _assignment; + } + MaxStrategy<T>& operator=(const MaxStrategy& other) { if (_length != other._length) { _length = other._length; @@ -35,9 +39,6 @@ struct MaxStrategy { return *this; } - virtual ~MaxStrategy() { - delete[] _assignment; - } const unsigned int& operator[] (const MaxExpression<T> x) const { if (x.id() >= _length) { throw "Array out of bounds"; @@ -64,11 +65,11 @@ struct MaxStrategy { MaxStrategy<T> improve(const EquationSystem<T>& s, const VariableAssignment<T>& rho) const { MaxStrategy<T> newStrategy(*this); for (unsigned int i = 0; i < _length; ++i) { - const MaxExpression<T>* expr = s.getMax(i); - const T oldValue = (*this)(*expr, rho); - std::pair<const T,unsigned int> best = expr->bestStrategy(rho); + const MaxExpression<T>& expr = *s.getMax(i); + const T oldValue = (*this)(expr, rho); + std::pair<const T,unsigned int> best = expr.bestStrategy(rho); if (best.first > oldValue) - newStrategy[*expr] = best.second; + newStrategy[expr] = best.second; } std::cerr << "Strat improvement: "; if (_length > 0) |