[poincare] Fix convention on compareTo

Change-Id: Ia1a7f2f23b93bec6a856da04baf109dfe8f49980
This commit is contained in:
Émilie Feral
2017-09-27 17:37:42 +02:00
parent 308c48daf8
commit 273efcc2f9
2 changed files with 8 additions and 4 deletions

View File

@@ -116,6 +116,10 @@ public:
/* Sorting */
virtual bool isCommutative() const { return false; }
virtual void sort();
/* compareTo returns:
* 1 if this > e
* -1 if this < e
* 0 if this == e */
virtual int compareTo(const Expression * e) const;
/* Layout Engine */

View File

@@ -97,12 +97,12 @@ void Expression::sort() {
}
int Expression::compareTo(const Expression * e) const {
if (e->type() > this->type()) {
return 1;
}
if (e->type() < this->type()) {
if (this->type() < e->type()) {
return -1;
}
if (this->type() > e->type()) {
return 1;
}
for (int i = 0; i < this->numberOfOperands(); i++) {
// The NULL node is the least node type.
if (e->numberOfOperands() <= i) {