Revert "[poincare] Rename addChildTreeAtIndex -> addChildAtIndex"

This reverts commit afd01f34e1.
This commit is contained in:
Léa Saviot
2018-08-03 16:02:56 +02:00
parent f28e029bb4
commit 7931d9ebfa
39 changed files with 106 additions and 106 deletions

View File

@@ -28,7 +28,7 @@ class AbsoluteValueLayoutRef : public LayoutReference {
public:
AbsoluteValueLayoutRef(TreeNode * n) : LayoutReference(n) {}
AbsoluteValueLayoutRef(LayoutRef l) : AbsoluteValueLayoutRef() {
addChildAtIndex(l, 0, 0);
addChildTreeAtIndex(l, 0, 0);
}
private:
AbsoluteValueLayoutRef() : LayoutReference() {

View File

@@ -45,8 +45,8 @@ public:
BinomialCoefficientLayoutRef(LayoutRef n, LayoutRef k) :
BinomialCoefficientLayoutRef()
{
addChildAtIndex(n, 0, 0);
addChildAtIndex(k, 1, 1);
addChildTreeAtIndex(n, 0, 0);
addChildTreeAtIndex(k, 1, 1);
}
BinomialCoefficientLayoutRef(TreeNode * n) : LayoutReference(n) {}
private:

View File

@@ -26,7 +26,7 @@ class CeilingLayoutRef : public LayoutReference {
public:
CeilingLayoutRef(TreeNode * n) : LayoutReference(n) {}
CeilingLayoutRef(LayoutRef l) : CeilingLayoutRef() {
addChildAtIndex(l, 0, 0);
addChildTreeAtIndex(l, 0, 0);
}
private:
CeilingLayoutRef() : LayoutReference() {

View File

@@ -51,9 +51,9 @@ public:
CondensedSumLayoutRef(LayoutRef base, LayoutRef subscript, LayoutRef superscript) :
CondensedSumLayoutRef()
{
addChildAtIndex(base, 0, 0);
addChildAtIndex(subscript, 1, 1);
addChildAtIndex(superscript, 2, 2);
addChildTreeAtIndex(base, 0, 0);
addChildTreeAtIndex(subscript, 1, 1);
addChildTreeAtIndex(superscript, 2, 2);
}
CondensedSumLayoutRef(TreeNode * n) : LayoutReference(n) {}

View File

@@ -42,7 +42,7 @@ private:
class ConjugateLayoutRef : public LayoutReference {
public:
ConjugateLayoutRef(LayoutRef l) : ConjugateLayoutRef() {
addChildAtIndex(l, 0, 0);
addChildTreeAtIndex(l, 0, 0);
}
ConjugateLayoutRef(TreeNode * n) : LayoutReference(n) {}
private:

View File

@@ -27,7 +27,7 @@ class FloorLayoutRef : public LayoutReference {
public:
FloorLayoutRef(TreeNode * n) : LayoutReference(n) {}
FloorLayoutRef(LayoutRef l) : FloorLayoutRef() {
addChildAtIndex(l, 0, 0);
addChildTreeAtIndex(l, 0, 0);
}
private:
FloorLayoutRef() : LayoutReference() {

View File

@@ -56,8 +56,8 @@ public:
FractionLayoutRef(LayoutRef numerator, LayoutRef denominator) :
FractionLayoutRef()
{
addChildAtIndex(numerator, 0, 0);
addChildAtIndex(denominator, 1, 1);
addChildTreeAtIndex(numerator, 0, 0);
addChildTreeAtIndex(denominator, 1, 1);
}
FractionLayoutRef(TreeNode * n) : LayoutReference(n) {}
private:

View File

@@ -69,26 +69,26 @@ public:
}
HorizontalLayoutRef(LayoutRef l) : HorizontalLayoutRef() {
addChildAtIndex(l, 0, 0);
addChildTreeAtIndex(l, 0, 0);
}
HorizontalLayoutRef(LayoutRef l1, LayoutRef l2) : HorizontalLayoutRef() {
addChildAtIndex(l1, 0, 0);
addChildAtIndex(l2, 1, 1);
addChildTreeAtIndex(l1, 0, 0);
addChildTreeAtIndex(l2, 1, 1);
}
HorizontalLayoutRef(LayoutRef l1, LayoutRef l2, LayoutRef l3) : HorizontalLayoutRef() {
addChildAtIndex(l1, 0, 0);
addChildAtIndex(l2, 1, 1);
addChildAtIndex(l3, 2, 2);
addChildTreeAtIndex(l1, 0, 0);
addChildTreeAtIndex(l2, 1, 1);
addChildTreeAtIndex(l3, 2, 2);
}
HorizontalLayoutRef(LayoutRef l1, LayoutRef l2, LayoutRef l3, LayoutRef l4) : HorizontalLayoutRef() {
addChildAtIndex(l1, 0, 0);
addChildAtIndex(l2, 1, 1);
addChildAtIndex(l3, 2, 2);
addChildAtIndex(l4, 3, 3);
addChildTreeAtIndex(l1, 0, 0);
addChildTreeAtIndex(l2, 1, 1);
addChildTreeAtIndex(l3, 2, 2);
addChildTreeAtIndex(l4, 3, 3);
}
void addChildAtIndex(TreeReference t, int index, int currentNumberOfChildren) override {
ExpressionReference::addChildAtIndex(t, index, currentNumberOfChildren);
void addChildTreeAtIndex(TreeReference t, int index, int currentNumberOfChildren) override {
ExpressionReference::addChildTreeAtIndex(t, index, currentNumberOfChildren);
}
// Remove puts a child at the end of the pool
void removeChildAtIndex(int i) override {

View File

@@ -58,9 +58,9 @@ public:
IntegralLayoutRef(LayoutRef integrand, LayoutRef lowerBound, LayoutRef upperBound) :
IntegralLayoutRef()
{
addChildAtIndex(integrand, 0, 0);
addChildAtIndex(lowerBound, 1, 1);
addChildAtIndex(upperBound, 2, 2);
addChildTreeAtIndex(integrand, 0, 0);
addChildTreeAtIndex(lowerBound, 1, 1);
addChildTreeAtIndex(upperBound, 2, 2);
}
IntegralLayoutRef(TreeNode * n) : LayoutReference(n) {}
private:

View File

@@ -73,7 +73,7 @@ public:
// Tree modification
// Add
void addChildAtIndex(LayoutReference l, int index, int currentNumberOfChildren, LayoutCursor * cursor);
void addChildTreeAtIndex(LayoutReference l, int index, int currentNumberOfChildren, LayoutCursor * cursor);
void addSibling(LayoutCursor * cursor, LayoutReference sibling, bool moveCursor);
// Replace
//void replaceChildAtIndex(int oldChildIndex, LayoutReference newChild) { TreeReference::replaceTreeChildAtIndex(oldChildIndex, newChild); }

View File

@@ -55,7 +55,7 @@ public:
MatrixNode * typedNode() const { assert(!isAllocationFailure()); return static_cast<MatrixNode *>(node()); }
int numberOfRows() const;
int numberOfColumns() const;
void addChildAtIndex(TreeReference t, int index, int currentNumberOfChildren) override;
void addChildTreeAtIndex(TreeReference t, int index, int currentNumberOfChildren) override;
ExpressionReference matrixChild(int i, int j) { assert(!isAllocationFailure()); return childAtIndex(i*numberOfColumns()+j); }
/* Operation on matrix */

View File

@@ -60,7 +60,7 @@ public:
int numberOfRows() const;
int numberOfColumns() const;
void setDimensions(int rows, int columns);
void addChildAtIndex(TreeReference t, int index, int currentNumberOfChildren) override;
void addChildTreeAtIndex(TreeReference t, int index, int currentNumberOfChildren) override;
private:
void setNumberOfRows(int rows);
void setNumberOfColumns(int columns);

View File

@@ -64,10 +64,10 @@ public:
MatrixLayoutRef(LayoutRef l1, LayoutRef l2, LayoutRef l3, LayoutRef l4) :
MatrixLayoutRef()
{
addChildAtIndex(l1, 0, 0);
addChildAtIndex(l2, 1, 1);
addChildAtIndex(l3, 2, 2);
addChildAtIndex(l4, 3, 3);
addChildTreeAtIndex(l1, 0, 0);
addChildTreeAtIndex(l2, 1, 1);
addChildTreeAtIndex(l3, 2, 2);
addChildTreeAtIndex(l4, 3, 3);
setDimensions(2, 2);
}
@@ -102,7 +102,7 @@ public:
}
}
void setDimensions(int rows, int columns);
void addChildAtIndex(TreeReference t, int index, int currentNumberOfChildren) override;
void addChildTreeAtIndex(TreeReference t, int index, int currentNumberOfChildren) override;
private:
MatrixLayoutNode * typedNode() const { assert(!isAllocationFailure()); return static_cast<MatrixLayotuNode *>(node()); }
void setNumberOfRows(int rows);

View File

@@ -33,8 +33,8 @@ private:
class NAryExpressionRef : public ExpressionReference {
public:
void addChildAtIndex(TreeReference t, int index, int currentNumberOfChildren) override {
ExpressionReference::addChildAtIndex(t, index, currentNumberOfChildren);
void addChildTreeAtIndex(TreeReference t, int index, int currentNumberOfChildren) override {
ExpressionReference::addChildTreeAtIndex(t, index, currentNumberOfChildren);
}
// Remove puts a child at the end of the pool
void removeChildAtIndex(int i) override {

View File

@@ -69,19 +69,19 @@ public:
NthRootLayoutRef(TreeNode * n) : LayoutReference(n) {}
NthRootLayoutRef(LayoutRef radicand) : NthRootLayoutRef() {
addChildAtIndex(radicand, 0, 0);
addChildTreeAtIndex(radicand, 0, 0);
if (!node()->isAllocationFailure()) {
static_cast<NthRootLayoutNode *>(node())->setNumberOfChildren(1);
}
}
NthRootLayoutRef(LayoutRef radicand, LayoutRef index) : NthRootLayoutRef() {
addChildAtIndex(radicand, 0, 0);
addChildTreeAtIndex(radicand, 0, 0);
if (node()->isAllocationFailure()) {
return;
}
static_cast<NthRootLayoutNode *>(node())->setNumberOfChildren(1);
addChildAtIndex(index, 1, 1);
addChildTreeAtIndex(index, 1, 1);
if (!node()->isAllocationFailure()) {
static_cast<NthRootLayoutNode *>(node())->setNumberOfChildren(2);
}

View File

@@ -39,7 +39,7 @@ public:
ParenthesisReference(ExpressionReference exp) {
TreeNode * node = TreePool::sharedPool()->createTreeNode<ParenthesisNode>();
m_identifier = node->identifier();
addChildAtIndex(exp, 0, 0);
addChildTreeAtIndex(exp, 0, 0);
}
};

View File

@@ -27,9 +27,9 @@ public:
ProductLayoutRef(LayoutRef argument, LayoutRef lowerB, LayoutRef upperB) :
ProductLayoutRef()
{
addChildAtIndex(argument, 0, 0);
addChildAtIndex(lowerB, 1, 1);
addChildAtIndex(upperB, 2, 2);
addChildTreeAtIndex(argument, 0, 0);
addChildTreeAtIndex(lowerB, 1, 1);
addChildTreeAtIndex(upperB, 2, 2);
}
private:
ProductLayoutRef() : LayoutReference() {

View File

@@ -20,9 +20,9 @@ public:
SumLayoutRef(LayoutRef argument, LayoutRef lowerB, LayoutRef upperB) :
SumLayoutRef()
{
addChildAtIndex(argument, 0, 0);
addChildAtIndex(lowerB, 1, 1);
addChildAtIndex(upperB, 2, 2);
addChildTreeAtIndex(argument, 0, 0);
addChildTreeAtIndex(lowerB, 1, 1);
addChildTreeAtIndex(upperB, 2, 2);
}
private:
SumLayoutRef() : LayoutReference() {

View File

@@ -113,7 +113,7 @@ public:
protected:
// Hierarchy operations
// Add
virtual void addChildAtIndex(TreeReference t, int index, int currentNumberOfChildren);
virtual void addChildTreeAtIndex(TreeReference t, int index, int currentNumberOfChildren);
// Remove puts a child at the end of the pool
virtual void removeChildAtIndex(int i);
virtual void removeChild(TreeReference t, int childNumberOfChildren);

View File

@@ -66,7 +66,7 @@ public:
if (!(node()->isAllocationFailure())) {
static_cast<VerticalOffsetLayoutNode *>(node())->setType(type);
}
addChildAtIndex(l, 0, 0);
addChildTreeAtIndex(l, 0, 0);
}
private:
VerticalOffsetLayoutRef() : LayoutReference() {

View File

@@ -40,9 +40,9 @@ template<typename T> EvaluationReference<T> ApproximationEngine::map(const Expre
for (int i = 0; i < result.numberOfRows()*result.numberOfColumns(); i++) {
ComplexNode<T> * child = static_cast<MatrixComplexNode<T> *>(m.node())->childAtIndex(i);
if (child) {
result.addChildAtIndex(compute(*child, angleUnit), i, i);
result.addChildTreeAtIndex(compute(*child, angleUnit), i, i);
} else {
result.addChildAtIndex(ComplexReference<T>::Undefined(), i, i);
result.addChildTreeAtIndex(ComplexReference<T>::Undefined(), i, i);
}
}
result.setDimensions(m.numberOfRows(), m.numberOfColumns());
@@ -95,9 +95,9 @@ template<typename T> MatrixComplexReference<T> ApproximationEngine::elementWiseO
for (int i = 0; i < m.numberOfChildren(); i++) {
ComplexNode<T> * child = static_cast<MatrixComplexNode<T> *>(m.node())->childAtIndex(i);
if (child) {
matrix.addChildAtIndex(computeOnComplexes(*child, c), i, i);
matrix.addChildTreeAtIndex(computeOnComplexes(*child, c), i, i);
} else {
matrix.addChildAtIndex(ComplexReference<T>::Undefined(), i, i);
matrix.addChildTreeAtIndex(ComplexReference<T>::Undefined(), i, i);
}
}
matrix.setDimensions(m.numberOfRows(), m.numberOfColumns());
@@ -116,9 +116,9 @@ template<typename T> MatrixComplexReference<T> ApproximationEngine::elementWiseO
ComplexNode<T> * childM = static_cast<MatrixComplexNode<T> *>(m.node())->childAtIndex(i);
ComplexNode<T> * childN = static_cast<MatrixComplexNode<T> *>(n.node())->childAtIndex(i);
if (childM && childN) {
matrix.addChildAtIndex(computeOnComplexes(*childM, *childN), i, i);
matrix.addChildTreeAtIndex(computeOnComplexes(*childM, *childN), i, i);
} else {
matrix.addChildAtIndex(ComplexReference<T>::Undefined(), i, i);
matrix.addChildTreeAtIndex(ComplexReference<T>::Undefined(), i, i);
}
}
matrix.setDimensions(m.numberOfRows(), m.numberOfColumns());

View File

@@ -52,7 +52,7 @@ ExpressionReference Equal::shallowReduce(Context& context, Preferences::AngleUni
LayoutRef Equal::createLayout(Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const {
HorizontalLayoutRef result;
result.addOrMergeChildAtIndex(operand(0)->createLayout(floatDisplayMode, numberOfSignificantDigits), 0, false);
result.addChildAtIndex(CharLayoutRef('='), result.numberOfChildren(), result.numberOfChildren(), nullptr);
result.addChildTreeAtIndex(CharLayoutRef('='), result.numberOfChildren(), result.numberOfChildren(), nullptr);
result.addOrMergeChildAtIndex(operand(1)->createLayout(floatDisplayMode, numberOfSignificantDigits), result.numberOfChildren(), false);
return result;
}

View File

@@ -23,7 +23,7 @@ ExpressionReference ExpressionNode::replaceSymbolWithExpression(char symbol, Exp
for (int i = 0; i < nbChildren; i++) {
ExpressionReference newChild = reference.childAtIndex(i).node()->replaceSymbolWithExpression(symbol, expression);
if (reference.numberOfChildren() < nbChildren) {
reference.addChildAtIndex(newChild, i, nbChildren - 1);
reference.addChildTreeAtIndex(newChild, i, nbChildren - 1);
} else {
reference.replaceTreeChildAtIndex(i, newChild);
}

View File

@@ -202,7 +202,7 @@ ExpressionReference ExpressionReference::deepReduce(Context & context, Preferenc
for (int i = 0; i < nbChildren; i++) {
ExpressionReference reducedChild = childAtIndex(i).deepReduce(context, angleUnit);
if (numberOfChildren() < nbChildren) {
addChildAtIndex(reducedChild, i, nbChildren-1);
addChildTreeAtIndex(reducedChild, i, nbChildren-1);
} else {
replaceTreeChildAtIndex(i, reducedChild);
}
@@ -216,7 +216,7 @@ ExpressionReference ExpressionReference::deepBeautify(Context & context, Prefere
for (int i = 0; i < nbChildren; i++) {
ExpressionReference beautifiedChild = beautifiedExpression.childAtIndex(i).deepBeautify(context, angleUnit);
if (beautifiedExpression.numberOfChildren() < nbChildren) {
beautifiedExpression.addChildAtIndex(beautifiedChild, i, nbChildren-1);
beautifiedExpression.addChildTreeAtIndex(beautifiedChild, i, nbChildren-1);
} else {
beautifiedExpression.replaceTreeChildAtIndex(i, beautifiedChild);
}

View File

@@ -96,7 +96,7 @@ LayoutRef Factorial::createLayout(Preferences::PrintFloatMode floatDisplayMode,
HorizontalLayoutRef result;
result.addOrMergeChildAtIndex(operand(0)->createLayout(floatDisplayMode, numberOfSignificantDigits), 0, false);
int childrenCount = result.numberOfChildren();
result.addChildAtIndex(CharLayoutRef('!'), childrenCount, childrenCount, nullptr);
result.addChildTreeAtIndex(CharLayoutRef('!'), childrenCount, childrenCount, nullptr);
return result;
}

View File

@@ -96,7 +96,7 @@ void GridLayoutNode::addEmptyRow(EmptyLayoutNode::Color color) {
int previousNumberOfChildren = numberOfChildren();
int columnsCount = m_numberOfColumns;
for (int i = 0; i < columnsCount; i++) {
thisRef.addChildAtIndex(
thisRef.addChildTreeAtIndex(
EmptyLayoutRef(color),
previousNumberOfChildren,
previousNumberOfChildren + i,
@@ -114,7 +114,7 @@ void GridLayoutNode::addEmptyColumn(EmptyLayoutNode::Color color) {
int rowsCount = m_numberOfRows;
int futureColumnsCount = m_numberOfColumns + 1;
for (int i = 0; i < rowsCount; i++) {
thisRef.addChildAtIndex(
thisRef.addChildTreeAtIndex(
EmptyLayoutRef(color),
i*futureColumnsCount + futureColumnsCount-1,
previousNumberOfChildren + i,

View File

@@ -245,7 +245,7 @@ void HorizontalLayoutNode::didRemoveChildAtIndex(int index, LayoutCursor * curso
* sibling (e.g. a VerticalOffsetLayout), add an empty layout at index 0 */
if (!force && index == 0 && numberOfChildren() > 0 && childAtIndex(0)->mustHaveLeftSibling()) {
LayoutRef(this).addChildAtIndex(EmptyLayoutRef(), 0, numberOfChildren(), cursor);
LayoutRef(this).addChildTreeAtIndex(EmptyLayoutRef(), 0, numberOfChildren(), cursor);
}
}
@@ -347,7 +347,7 @@ void HorizontalLayoutRef::addOrMergeChildAtIndex(LayoutRef l, int index, bool re
if (l.isHorizontal()) {
mergeChildrenAtIndex(HorizontalLayoutRef(l.node()), index, removeEmptyChildren, cursor);
} else {
addChildAtIndex(l, index, numberOfChildren(),cursor);
addChildTreeAtIndex(l, index, numberOfChildren(),cursor);
}
}

View File

@@ -422,7 +422,7 @@ T IntegerNode::templatedApproximate() const {
LayoutRef IntegerNode::createLayout(Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const {
LayoutRef naturalLayout = NaturalIntegerAbstract::createLayout();
if (m_negative) {
naturalLayout.addChildAtIndex(CharLayoutRef('-'), 0, naturalLayout.numberOfChildren(), nullptr);
naturalLayout.addChildTreeAtIndex(CharLayoutRef('-'), 0, naturalLayout.numberOfChildren(), nullptr);
}
return naturalLayout;
}

View File

@@ -34,7 +34,7 @@ LayoutRef LayoutEngine::createPrefixLayout(const Expression * expression, Prefer
if (numberOfChildren > 0) {
args.addOrMergeChildAtIndex(expression->operand(0)->createLayout(floatDisplayMode, numberOfSignificantDigits), 0, true);
for (int i = 1; i < numberOfChildren; i++) {
args.addChildAtIndex(CharLayoutRef(','), args.numberOfChildren(), args.numberOfChildren(), nullptr);
args.addChildTreeAtIndex(CharLayoutRef(','), args.numberOfChildren(), args.numberOfChildren(), nullptr);
args.addOrMergeChildAtIndex(expression->operand(i)->createLayout(floatDisplayMode, numberOfSignificantDigits), args.numberOfChildren(), true);
}
}
@@ -45,11 +45,11 @@ LayoutRef LayoutEngine::createPrefixLayout(const Expression * expression, Prefer
LayoutRef LayoutEngine::createParenthesedLayout(LayoutRef layoutRef, bool cloneLayout) {
HorizontalLayoutRef result;
result.addChildAtIndex(LeftParenthesisLayoutRef(), 0, 0);
result.addChildTreeAtIndex(LeftParenthesisLayoutRef(), 0, 0);
if (layoutRef.isDefined()) {
result.addOrMergeChildAtIndex(cloneLayout ? layoutRef.clone() : layoutRef, 1, true);
}
result.addChildAtIndex(RightParenthesisLayoutRef(), result.numberOfChildren(), result.numberOfChildren());
result.addChildTreeAtIndex(RightParenthesisLayoutRef(), result.numberOfChildren(), result.numberOfChildren());
return result;
}
@@ -57,7 +57,7 @@ LayoutRef LayoutEngine::createStringLayout(const char * buffer, int bufferSize,
assert(bufferSize > 0);
HorizontalLayoutRef resultLayout;
for (int i = 0; i < bufferSize; i++) {
resultLayout.addChildAtIndex(CharLayoutRef(buffer[i], fontSize), i, i, nullptr);
resultLayout.addChildTreeAtIndex(CharLayoutRef(buffer[i], fontSize), i, i, nullptr);
}
return resultLayout;
}
@@ -65,7 +65,7 @@ LayoutRef LayoutEngine::createStringLayout(const char * buffer, int bufferSize,
LayoutRef LayoutEngine::createLogLayout(LayoutRef argument, LayoutRef index) {
HorizontalLayoutRef resultLayout = HorizontalLayoutRef(createStringLayout("log", 3));
VerticalOffsetLayoutRef offsetLayout = VerticalOffsetLayoutRef(index, VerticalOffsetLayoutNode::Type::Subscript);
resultLayout.addChildAtIndex(offsetLayout, resultLayout.numberOfChildren(), resultLayout.numberOfChildren(), nullptr);
resultLayout.addChildTreeAtIndex(offsetLayout, resultLayout.numberOfChildren(), resultLayout.numberOfChildren(), nullptr);
resultLayout.addOrMergeChildAtIndex(createParenthesedLayout(argument, false), resultLayout.numberOfChildren(), true);
return resultLayout;
}

View File

@@ -80,7 +80,7 @@ void LayoutReference::replaceWithJuxtapositionOf(LayoutRef leftChild, LayoutRef
p.removeChild(*this, cursor->layoutReference() == *this ? cursor : nullptr);
}
void LayoutReference::addChildAtIndex(LayoutRef l, int index, int currentNumberOfChildren, LayoutCursor * cursor) {
void LayoutReference::addChildTreeAtIndex(LayoutRef l, int index, int currentNumberOfChildren, LayoutCursor * cursor) {
int newIndex = index;
int newCurrentNumberOfChildren = currentNumberOfChildren;
if (!this->node()->willAddChildAtIndex(l.node(), &newIndex, &newCurrentNumberOfChildren, cursor)) {
@@ -98,7 +98,7 @@ void LayoutReference::addChildAtIndex(LayoutRef l, int index, int currentNumberO
}
}
this->addChildAtIndex(l, newIndex, newCurrentNumberOfChildren);
this->addChildTreeAtIndex(l, newIndex, newCurrentNumberOfChildren);
if (cursor != nullptr) {
if (this->isAllocationFailure()) {

View File

@@ -23,7 +23,7 @@ LayoutRef MatrixNode::createLayout(Preferences::PrintFloatMode floatDisplayMode,
layout.setNumberOfColumns(1);
LayoutRef castedLayout(layout.node());
for (int i = 0; i < numberOfChildren(); i++) {
castedLayout.addChildAtIndex(childAtIndex(i)->createLayout(floatDisplayMode, numberOfSignificantDigits), i, i, nullptr);
castedLayout.addChildTreeAtIndex(childAtIndex(i)->createLayout(floatDisplayMode, numberOfSignificantDigits), i, i, nullptr);
layout.setNumberOfRows(i+1);
}
layout.setNumberOfRows(m_numberOfRows);
@@ -83,9 +83,9 @@ EvaluationReference<T> MatrixNode::templatedApproximate(Context& context, Prefer
for (int i = 0; i < numberOfChildren(); i++) {
EvaluationReference<T> operandEvaluation = childAtIndex(i)->approximate(T(), context, angleUnit);
if (operandEvaluation.node()->type() != Evaluation<T>::Type::Complex) {
result.addChildAtIndex(ComplexReference<T>::Undefined(), i, i);
result.addChildTreeAtIndex(ComplexReference<T>::Undefined(), i, i);
} else {
result.addChildAtIndex(compute(*child, angleUnit), i, i);
result.addChildTreeAtIndex(compute(*child, angleUnit), i, i);
}
}
matrix.setDimensions(m.numberOfRows(), m.numberOfColumns());
@@ -117,8 +117,8 @@ int MatrixReference::numberOfColumns() const {
return typedNode()->numberOfColumns();
}
void MatrixReference::addChildAtIndex(TreeReference t, int index, int currentNumberOfChildren) {
ExpressionReference::addChildAtIndex(t, index, currentNumberOfChildren);
void MatrixReference::addChildTreeAtIndex(TreeReference t, int index, int currentNumberOfChildren) {
ExpressionReference::addChildTreeAtIndex(t, index, currentNumberOfChildren);
if (isAllocationFailure()) {
return;
}
@@ -163,7 +163,7 @@ void MatrixReference::rowCanonize(Context & context, Preferences::AngleUnit angl
// No non-null coefficient in this column, skip
k++;
// Update determinant: det *= 0
if (determinant) { determinant.addChildAtIndex(RationalReference(0), 0, determinant.numberOfChildren()); }
if (determinant) { determinant.addChildTreeAtIndex(RationalReference(0), 0, determinant.numberOfChildren()); }
} else {
// Swap row h and iPivot
if (iPivot != h) {
@@ -171,12 +171,12 @@ void MatrixReference::rowCanonize(Context & context, Preferences::AngleUnit angl
swapChildren(iPivot*n+col, h*n+col);
}
// Update determinant: det *= -1
if (determinant) { determinant.addChildAtIndex(RationalReference(-1), 0, determinant.numberOfChildren()); }
if (determinant) { determinant.addChildTreeAtIndex(RationalReference(-1), 0, determinant.numberOfChildren()); }
}
/* Set to 1 M[h][k] by linear combination */
ExpressionReference divisor = matrixChild(h, k);
// Update determinant: det *= divisor
if (determinant) { determinant.addChildAtIndex(divisor.clone()); }
if (determinant) { determinant.addChildTreeAtIndex(divisor.clone()); }
for (int j = k+1; j < n; j++) {
ExpressionReference opHJ = matrixChild(h, j);
ExpressionReference newOpHJ = DivisionReference(opHJ, divisor.clone());

View File

@@ -39,9 +39,9 @@ ExpressionReference MatrixComplexNode<T>::complexToExpression(Preferences::Compl
for (int i = 0; i < numberOfComplexOperands(); i++) {
ComplexNode<T> * child = childAtIndex(i);
if (child) {
matrix.addChildAtIndex(child->complexToExpression(complexFormat), i, i);
matrix.addChildTreeAtIndex(child->complexToExpression(complexFormat), i, i);
} else {
matrix.addChildAtIndex(UndefinedReference(), i, i);
matrix.addChildTreeAtIndex(UndefinedReference(), i, i);
}
}
matrix.setDimensions(numberOfRows(), numberOfColumns());
@@ -113,9 +113,9 @@ EvaluationReference<T> MatrixComplexNode<T>::transpose() const {
for (int j = 0; j < numberOfColumns(); j++) {
ComplexNode<T> * child = childAtIndex(i*numberOfColumns()+i);
if (child) {
result.addChildAtIndex(child, j*numberOfRows()+i, j*numberOfRows()+i);
result.addChildTreeAtIndex(child, j*numberOfRows()+i, j*numberOfRows()+i);
} else {
result.addChildAtIndex(ComplexReference<T>::Undefined(), j*numberOfRows()+i, j*numberOfRows()+i);
result.addChildTreeAtIndex(ComplexReference<T>::Undefined(), j*numberOfRows()+i, j*numberOfRows()+i);
}
}
}
@@ -138,7 +138,7 @@ MatrixComplexReference<T>::MatrixComplexReference(std::complex<T> * operands, in
MatrixComplexReference<T>()
{
for (int i=0; i<numberOfRows*numberOfColumns; i++) {
addChildAtIndex(ComplexReference<T>(operands[i]), i, i);
addChildTreeAtIndex(ComplexReference<T>(operands[i]), i, i);
}
setDimensions(numberOfRows, numberOfColumns);
}
@@ -149,7 +149,7 @@ MatrixComplexReference<T> MatrixComplexReference<T>::createIdentity(int dim) {
for (int i = 0; i < dim; i++) {
for (int j = 0; j < dim; j++) {
ComplexReference<T> c = i == j ? ComplexReference<T>(1.0) : ComplexReference<T>(0.0);
result.addChildAtIndex(c, i*dim+j, i*dim+j);
result.addChildTreeAtIndex(c, i*dim+j, i*dim+j);
}
}
result.setDimensions(dim, dim);
@@ -183,8 +183,8 @@ void MatrixComplexReference<T>::setDimensions(int rows, int columns) {
}
template<typename T>
void MatrixComplexReference<T>::addChildAtIndex(TreeReference t, int index, int currentNumberOfChildren) {
ExpressionReference::addChildAtIndex(t, index, currentNumberOfChildren);
void MatrixComplexReference<T>::addChildTreeAtIndex(TreeReference t, int index, int currentNumberOfChildren) {
ExpressionReference::addChildTreeAtIndex(t, index, currentNumberOfChildren);
if (isAllocationFailure()) {
return;
}

View File

@@ -296,8 +296,8 @@ void MatrixLayoutRef::setDimensions(int rows, int columns) {
setNumberOfColumns(columns);
}
void MatrixLayoutRef::addChildAtIndex(TreeReference t, int index, int currentNumberOfChildren) {
ExpressionReference::addChildAtIndex(t, index, currentNumberOfChildren);
void MatrixLayoutRef::addChildTreeAtIndex(TreeReference t, int index, int currentNumberOfChildren) {
ExpressionReference::addChildTreeAtIndex(t, index, currentNumberOfChildren);
if (isAllocationFailure()) {
return;
}

View File

@@ -179,7 +179,7 @@ LayoutRef Power::createLayout(Preferences::PrintFloatMode floatDisplayMode, int
}
HorizontalLayoutRef result = HorizontalLayoutRef();
result.addOrMergeChildAtIndex(m_operands[0]->createLayout(floatDisplayMode, numberOfSignificantDigits), 0, false);
result.addChildAtIndex(VerticalOffsetLayoutRef(
result.addChildTreeAtIndex(VerticalOffsetLayoutRef(
indiceOperand->createLayout(floatDisplayMode, numberOfSignificantDigits),
VerticalOffsetLayoutNode::Type::Superscript),
result.numberOfChildren(),

View File

@@ -89,7 +89,7 @@ void RationalNode::setSign(Sign s) {
LayoutRef RationalNode::createLayout(Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const {
LayoutRef numeratorLayout = numerator().createLayout();
if (m_negative) {
numeratorLayout.addChildAtIndex(CharLayoutRef('-'), 0, numeratorLayout.numberOfChildren(), nullptr);
numeratorLayout.addChildTreeAtIndex(CharLayoutRef('-'), 0, numeratorLayout.numberOfChildren(), nullptr);
}
if (denominator().isOne()) {
return numeratorLayout;

View File

@@ -36,7 +36,7 @@ ExpressionReference Store::shallowReduce(Context& context, Preferences::AngleUni
LayoutRef Store::createLayout(Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const {
HorizontalLayoutRef result = HorizontalLayoutRef();
result.addOrMergeChildAtIndex(value()->createLayout(floatDisplayMode, numberOfSignificantDigits), 0, false);
result.addChildAtIndex(CharLayoutRef(Ion::Charset::Sto), result.numberOfChildren(), result.numberOfChildren(), nullptr);
result.addChildTreeAtIndex(CharLayoutRef(Ion::Charset::Sto), result.numberOfChildren(), result.numberOfChildren(), nullptr);
result.addOrMergeChildAtIndex(symbol()->createLayout(floatDisplayMode, numberOfSignificantDigits), result.numberOfChildren(), false);
return result;
}

View File

@@ -137,7 +137,7 @@ void TreeReference::replaceWithAllocationFailure(int currentNumberOfChildren) {
* no longer retaining the node. When we add this node to the parent, it
* will retain it and increment the retain count. */
newAllocationFailureNode->setReferenceCounter(currentRetainCount - 1);
p.addChildAtIndex(TreeRef(newAllocationFailureNode), indexInParentNode, p.numberOfChildren() - 1);
p.addChildTreeAtIndex(TreeRef(newAllocationFailureNode), indexInParentNode, p.numberOfChildren() - 1);
p.decrementNumberOfChildren();
/* We decrement here the parent's number of children, as we did not do it
* before, see WARNING. */
@@ -183,7 +183,7 @@ void TreeReference::setTo(const TreeReference & tr) {
}
// Add
void TreeReference::addChildAtIndex(TreeReference t, int index, int currentNumberOfChildren) {
void TreeReference::addChildTreeAtIndex(TreeReference t, int index, int currentNumberOfChildren) {
assert(isDefined());
if (node()->isAllocationFailure()) {
return;

View File

@@ -253,16 +253,16 @@ bool VerticalOffsetLayoutNode::willAddSibling(LayoutCursor * cursor, LayoutNode
{
leftParenthesisIndex--;
}
parentRef.addChildAtIndex(leftParenthesis, leftParenthesisIndex, parentRef.numberOfChildren(), nullptr);
parentRef.addChildTreeAtIndex(leftParenthesis, leftParenthesisIndex, parentRef.numberOfChildren(), nullptr);
idxInParent = parentRef.indexOfChild(thisRef);
// Add the Right parenthesis
RightParenthesisLayoutRef rightParenthesis = RightParenthesisLayoutRef();
if (cursor->position() == LayoutCursor::Position::Right) {
parentRef.addChildAtIndex(rightParenthesis, idxInParent + 1, parentRef.numberOfChildren(), nullptr);
parentRef.addChildTreeAtIndex(rightParenthesis, idxInParent + 1, parentRef.numberOfChildren(), nullptr);
} else {
assert(cursor->position() == LayoutCursor::Position::Left);
parentRef.addChildAtIndex(rightParenthesis, idxInParent, parentRef.numberOfChildren(), nullptr);
parentRef.addChildTreeAtIndex(rightParenthesis, idxInParent, parentRef.numberOfChildren(), nullptr);
}
if (rightParenthesis.parent().isDefined()) {
cursor->setLayoutReference(rightParenthesis);

View File

@@ -15,18 +15,18 @@ QUIZ_CASE(poincare_parenthesis_layout_size) {
HorizontalLayout * layout = new HorizontalLayout();
LeftParenthesisLayout leftPar = new LeftParenthesisLayout();
RightParenthesisLayout rightPar = new RightParenthesisLayout();
layout->addChildAtIndex(leftPar, 0);
layout->addChildAtIndex(new CharLayout('2'), 1);
layout->addChildAtIndex(new CharLayout('+'), 2);
layout->addChildAtIndex(new LeftParenthesisLayout(), 3);
layout->addChildAtIndex(new FractionLayout(
layout->addChildTreeAtIndex(leftPar, 0);
layout->addChildTreeAtIndex(new CharLayout('2'), 1);
layout->addChildTreeAtIndex(new CharLayout('+'), 2);
layout->addChildTreeAtIndex(new LeftParenthesisLayout(), 3);
layout->addChildTreeAtIndex(new FractionLayout(
new CharLayout('3'),
new CharLayout('4')),
4);
layout->addChildAtIndex(new RightParenthesisLayout(), 3);
layout->addChildAtIndex(new CharLayout('6'), 5);
layout->addChildAtIndex(rightPar, 7);
layout->addChildAtIndex(new CharLayout('1'), 8);
layout->addChildTreeAtIndex(new RightParenthesisLayout(), 3);
layout->addChildTreeAtIndex(new CharLayout('6'), 5);
layout->addChildTreeAtIndex(rightPar, 7);
layout->addChildTreeAtIndex(new CharLayout('1'), 8);
assert(leftPar->size().height() == rightPar->size().height());
delete layout;
}