diff options
author | Carlo Zancanaro <carlo@pc-4w14-0.cs.usyd.edu.au> | 2012-06-15 16:02:55 +1000 |
---|---|---|
committer | Carlo Zancanaro <carlo@pc-4w14-0.cs.usyd.edu.au> | 2012-06-15 16:02:55 +1000 |
commit | 4769d5edec8e78225f8f67e864c3269f1d2616e4 (patch) | |
tree | edc95613cd16d319ac68ae1a375b28c32cd5f5be /impl/VariableAssignment.hpp | |
parent | fd6bc1887fecca5338e7d5660d56a4038c805d96 (diff) | |
parent | a61d8b829afab13593e254fc69e260b6346939dc (diff) |
Merge commit 'a61d'
Conflicts:
impl/Expression.hpp
impl/Operator.hpp
impl/Variable.hpp
impl/main.cpp
Diffstat (limited to 'impl/VariableAssignment.hpp')
-rw-r--r-- | impl/VariableAssignment.hpp | 30 |
1 files changed, 21 insertions, 9 deletions
diff --git a/impl/VariableAssignment.hpp b/impl/VariableAssignment.hpp index 9d8137a..e0f7dc8 100644 --- a/impl/VariableAssignment.hpp +++ b/impl/VariableAssignment.hpp @@ -1,17 +1,29 @@ #ifndef VARIABLE_ASSIGNMENT_HPP #define VARIABLE_ASSIGNMENT_HPP -#include "Variable.hpp" +#include "Expression.hpp" #include "IdMap.hpp" -template<typename T> -struct VariableAssignment : public IdMap<Variable<T>,T> { - VariableAssignment(unsigned int length) - : IdMap<Variable<T>,T>(length, -infinity<T>()) { } - VariableAssignment(unsigned int length, const T& initial) - : IdMap<Variable<T>,T>(length, initial) { } - VariableAssignment(const VariableAssignment& other) - : IdMap<Variable<T>,T>(other) { } +template<typename Domain> +struct VariableAssignment { + virtual ~VariableAssignment() { } + virtual const Domain& operator[](const Variable<Domain>&) const = 0; +}; + +template<typename Domain> +struct StableVariableAssignment +: public VariableAssignment<Domain>, public IdMap<Variable<Domain>, Domain> { + StableVariableAssignment(unsigned int length) + : IdMap<Variable<Domain>,Domain>(length, -infinity<Domain>()) { } + StableVariableAssignment(unsigned int length, const Domain& value) + : IdMap<Variable<Domain>,Domain>(length, value) { } + + const Domain& operator[](const Variable<Domain>& var) const { + return IdMap<Variable<Domain>,Domain>::operator[](var); + } + Domain& operator[](const Variable<Domain>& var) { + return IdMap<Variable<Domain>,Domain>::operator[](var); + } }; #endif |