summaryrefslogtreecommitdiff
path: root/impl/VariableAssignment.hpp
diff options
context:
space:
mode:
authorCarlo Zancanaro <carlo@pc-4w14-0.cs.usyd.edu.au>2012-04-30 21:17:07 +1000
committerCarlo Zancanaro <carlo@pc-4w14-0.cs.usyd.edu.au>2012-04-30 21:17:07 +1000
commite00c1e3f71bb1840e10a85af53469a81c73c7ef1 (patch)
tree8b24e7be29b364a5a17bdbaabeb3115261bba783 /impl/VariableAssignment.hpp
parent2c22cee1f8fa87c527449a8bdc668ea311fdaf64 (diff)
Functional algorithm. Unoptimised.
Diffstat (limited to 'impl/VariableAssignment.hpp')
-rw-r--r--impl/VariableAssignment.hpp18
1 files changed, 16 insertions, 2 deletions
diff --git a/impl/VariableAssignment.hpp b/impl/VariableAssignment.hpp
index a2d0afd..c0c7148 100644
--- a/impl/VariableAssignment.hpp
+++ b/impl/VariableAssignment.hpp
@@ -36,13 +36,13 @@ struct VariableAssignment {
return *this;
}
const T& operator[] (const Variable<T>& x) const {
- if (x.id() < 0 || x.id() >= _length) {
+ if (x.id() >= _length) {
throw "Array out of bounds";
}
return _assignment[x.id()];
}
T& operator[] (const Variable<T>& x) {
- if (x.id() < 0 || x.id() >= _length) {
+ if (x.id() >= _length) {
throw "Array out of bounds";
}
return _assignment[x.id()];
@@ -62,6 +62,20 @@ struct VariableAssignment {
}
return expansion;
}
+
+ bool operator==(const VariableAssignment& other) const {
+ if (_length != other._length)
+ return false;
+ for (unsigned int i = 0; i < _length; ++i) {
+ if (_assignment[i] != other._assignment[i]) {
+ return false;
+ }
+ }
+ return true;
+ }
+ bool operator!=(const VariableAssignment& other) const {
+ return !(*this == other);
+ }
private:
unsigned int _length;
T* _assignment;