From 273efcc2f9999a81a9631138edbfb3bd339c0fd4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89milie=20Feral?= Date: Wed, 27 Sep 2017 17:37:42 +0200 Subject: [PATCH] [poincare] Fix convention on compareTo Change-Id: Ia1a7f2f23b93bec6a856da04baf109dfe8f49980 --- poincare/include/poincare/expression.h | 4 ++++ poincare/src/expression.cpp | 8 ++++---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/poincare/include/poincare/expression.h b/poincare/include/poincare/expression.h index a89180c21..912bdf1a4 100644 --- a/poincare/include/poincare/expression.h +++ b/poincare/include/poincare/expression.h @@ -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 */ diff --git a/poincare/src/expression.cpp b/poincare/src/expression.cpp index 2acda2905..d18ab884d 100644 --- a/poincare/src/expression.cpp +++ b/poincare/src/expression.cpp @@ -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) {