Rename operand to child

This commit is contained in:
Léa Saviot
2018-06-22 10:24:14 +02:00
parent 287c9ca990
commit edce759ae5
3 changed files with 4 additions and 9 deletions

View File

@@ -17,8 +17,8 @@ public:
}
float approximate() override {
float result = 0.0f;
for (int i=0; i<numberOfOperands(); i++) {
result += operand(i)->approximate();
for (int i=0; i<numberOfChildren(); i++) {
result += child(i)->approximate();
}
return result;
}

View File

@@ -5,13 +5,8 @@
class ExpressionNode : public TreeNode {
public:
ExpressionNode() : TreeNode(TreePool::sharedPool()->generateIdentifier()) {
TreePool::sharedPool()->registerNode(this);
}
virtual float approximate() = 0;
int numberOfOperands() { return numberOfChildren(); }
ExpressionNode * operand(int i) { return static_cast<ExpressionNode *>(childAtIndex(i)); }
ExpressionNode * child(int i) { return static_cast<ExpressionNode *>(treeChildAtIndex(i)); }
};
#endif

View File

@@ -100,7 +100,7 @@ public:
return 0;
}
TreeNode * childAtIndex(int i) const {
TreeNode * treeChildAtIndex(int i) const {
assert(i >= 0);
assert(i < numberOfChildren());
TreeNode * child = next();