summaryrefslogtreecommitdiff
path: root/impl/MaxStrategy.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'impl/MaxStrategy.hpp')
-rw-r--r--impl/MaxStrategy.hpp15
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)