Numworks Epsilon  1.4.1
Graphing Calculator Operating System
dynamic_hierarchy.h
Go to the documentation of this file.
1 #ifndef POINCARE_DYNAMIC_HIERARCHY_H
2 #define POINCARE_DYNAMIC_HIERARCHY_H
3 
4 #include <poincare/expression.h>
6 #include <poincare/rational.h>
7 
8 namespace Poincare {
9 
10 class DynamicHierarchy : public Expression {
11 public:
13  DynamicHierarchy(const Expression * const * operands, int numberOfOperands, bool cloneOperands = true);
14  DynamicHierarchy(const Expression * operand1, const Expression * operand2, bool cloneOperands = true) :
15  DynamicHierarchy(ExpressionArray(operand1, operand2).array(), 2, cloneOperands) {}
17  DynamicHierarchy(const DynamicHierarchy & other) = delete;
18  DynamicHierarchy(DynamicHierarchy && other) = delete;
19  DynamicHierarchy& operator=(const DynamicHierarchy & other) = delete;
20  DynamicHierarchy& operator=(DynamicHierarchy && other) = delete;
21 
22  int numberOfOperands() const override { return m_numberOfOperands; }
23  const Expression * const * operands() const override { return m_operands; };
24 
25  void removeOperand(const Expression * e, bool deleteAfterRemoval = true);
26  void addOperands(const Expression * const * operands, int numberOfOperands);
28  void addOperandAtIndex(Expression * operand, int index);
30  typedef int (*ExpressionOrder)(const Expression * e1, const Expression * e2, bool canBeInterrupted);
31  void sortOperands(ExpressionOrder order, bool canBeInterrupted);
33 protected:
36 private:
37  void removeOperandAtIndex(int i, bool deleteAfterRemoval);
38  int simplificationOrderSameType(const Expression * e, bool canBeInterrupted) const override;
39  int simplificationOrderGreaterType(const Expression * e, bool canBeInterrupted) const override;
40 };
41 
42 }
43 
44 #endif
void removeOperand(const Expression *e, bool deleteAfterRemoval=true)
void addOperand(Expression *operand)
void addOperands(const Expression *const *operands, int numberOfOperands)
int(* ExpressionOrder)(const Expression *e1, const Expression *e2, bool canBeInterrupted)
const Expression ** m_operands
void addOperandAtIndex(Expression *operand, int index)
const Expression *const * operands() const override
void mergeOperands(DynamicHierarchy *d)
DynamicHierarchy(const Expression *operand1, const Expression *operand2, bool cloneOperands=true)
void sortOperands(ExpressionOrder order, bool canBeInterrupted)
int numberOfOperands() const override
const Expression * operand(int i) const
Definition: expression.cpp:78
DynamicHierarchy & operator=(const DynamicHierarchy &other)=delete