[poincare] Change methods names of TreeByReference: add 'InPlace'

This commit is contained in:
Émilie Feral
2018-08-07 14:19:30 +02:00
parent a8dbe44b05
commit ecc71f84b8
28 changed files with 84 additions and 84 deletions

View File

@@ -28,7 +28,7 @@ class AbsoluteValueLayoutRef : public LayoutReference {
public:
AbsoluteValueLayoutRef(TreeNode * n) : LayoutReference(n) {}
AbsoluteValueLayoutRef(LayoutRef l) : AbsoluteValueLayoutRef() {
replaceTreeChildAtIndex(0, l);
replaceChildAtIndexInPlace(0, l);
}
private:
AbsoluteValueLayoutRef() : LayoutReference(TreePool::sharedPool()->createTreeNode<AbsoluteValueLayoutNode>(), true) {}

View File

@@ -45,8 +45,8 @@ public:
BinomialCoefficientLayoutRef(LayoutRef n, LayoutRef k) :
BinomialCoefficientLayoutRef()
{
replaceTreeChildAtIndex(0, n);
replaceTreeChildAtIndex(1, k);
replaceChildAtIndexInPlace(0, n);
replaceChildAtIndexInPlace(1, k);
}
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() {
replaceTreeChildAtIndex(0, l);
replaceChildAtIndexInPlace(0, l);
}
private:
CeilingLayoutRef() : LayoutReference(TreePool::sharedPool()->createTreeNode<CeilingLayoutNode>(), true) {}

View File

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

View File

@@ -27,7 +27,7 @@ class FloorLayoutRef : public LayoutReference {
public:
FloorLayoutRef(TreeNode * n) : LayoutReference(n) {}
FloorLayoutRef(LayoutRef l) : FloorLayoutRef() {
replaceTreeChildAtIndex(0, l);
replaceChildAtIndexInPlace(0, l);
}
private:
FloorLayoutRef() : LayoutReference(TreePool::sharedPool()->createTreeNode<FloorLayoutNode>(), true) {}

View File

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

View File

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

View File

@@ -78,13 +78,13 @@ public:
//Add
void addSibling(LayoutCursor * cursor, LayoutReference sibling, bool moveCursor);
// Replace
//void replaceChildAtIndex(int oldChildIndex, LayoutReference newChild) { TreeReference::replaceTreeChildAtIndex(oldChildIndex, newChild); }
//void replaceChildAtIndex(int oldChildIndex, LayoutReference newChild) { TreeReference::replaceChildAtIndexInPlace(oldChildIndex, newChild); }
void replaceChild(LayoutReference oldChild, LayoutReference newChild, LayoutCursor * cursor = nullptr, bool force = false);
void replaceChildWithEmpty(LayoutReference oldChild, LayoutCursor * cursor = nullptr);
void replaceWith(LayoutReference newChild, LayoutCursor * cursor) {
LayoutReference p = parent();
assert(p.isDefined());
p.replaceChild(*this, newChild, cursor);
p.replaceChildInPlace(*this, newChild, cursor);
}
void replaceWithJuxtapositionOf(LayoutReference leftChild, LayoutReference rightChild, LayoutCursor * cursor, bool putCursorInTheMiddle = false);
// Collapse

View File

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

View File

@@ -43,7 +43,7 @@ private:
class OppositeReference : public ExpressionReference {
public:
OppositeReference(ExpressionReference operand) : ExpressionReference(TreePool::sharedPool()->createTreeNode<OppositeNode>(), true) {
replaceTreeChildAtIndex(0, operand);
replaceChildAtIndexInPlace(0, operand);
}
};

View File

@@ -37,7 +37,7 @@ private:
class ParenthesisReference : public ExpressionReference {
public:
ParenthesisReference(ExpressionReference exp) : ExpressionReference(TreePool::sharedPool()->createTreeNode<ParenthesisNode>(), true) {
replaceTreeChildAtIndex(0, exp);
replaceChildAtIndexInPlace(0, exp);
}
};

View File

@@ -27,9 +27,9 @@ public:
ProductLayoutRef(LayoutRef argument, LayoutRef lowerB, LayoutRef upperB) :
ProductLayoutRef()
{
replaceTreeChildAtIndex(0, argument);
replaceTreeChildAtIndex(1, lowerB);
replaceTreeChildAtIndex(2, upperB);
replaceChildAtIndexInPlace(0, argument);
replaceChildAtIndexInPlace(1, lowerB);
replaceChildAtIndexInPlace(2, upperB);
}
private:
ProductLayoutRef() : LayoutReference(TreePool::sharedPool()->createTreeNode<ProductLayoutNode>(), true) {}

View File

@@ -20,9 +20,9 @@ public:
SumLayoutRef(LayoutRef argument, LayoutRef lowerB, LayoutRef upperB) :
SumLayoutRef()
{
replaceTreeChildAtIndex(0, argument);
replaceTreeChildAtIndex(1, lowerB);
replaceTreeChildAtIndex(2, upperB);
replaceChildAtIndexInPlace(0, argument);
replaceChildAtIndexInPlace(1, lowerB);
replaceChildAtIndexInPlace(2, upperB);
}
private:
SumLayoutRef() : LayoutReference(TreePool::sharedPool()->createTreeNode<SumLayoutNode>(), true) {}

View File

@@ -86,19 +86,19 @@ public:
/* Hierarchy operations */
// Replace
void replaceWith(TreeByReference t);
void replaceTreeChild(TreeByReference oldChild, TreeByReference newChild);
void replaceTreeChildAtIndex(int oldChildIndex, TreeByReference newChild) {
void replaceWithInPlace(TreeByReference t);
void replaceChildInPlace(TreeByReference oldChild, TreeByReference newChild);
void replaceChildAtIndexInPlace(int oldChildIndex, TreeByReference newChild) {
assert(oldChildIndex >= 0 && oldChildIndex < numberOfChildren());
TreeByReference oldChild = treeChildAtIndex(oldChildIndex);
replaceTreeChild(oldChild, newChild);
replaceChildInPlace(oldChild, newChild);
}
void replaceWithAllocationFailure(int currentNumberOfChildren);
void replaceChildWithGhost(TreeByReference t);
void replaceWithAllocationFailureInPlace(int currentNumberOfChildren);
void replaceChildWithGhostInPlace(TreeByReference t);
// Merge
void mergeTreeChildrenAtIndex(TreeByReference t, int i);
void mergeChildrenAtIndexInPlace(TreeByReference t, int i);
// Swap
void swapChildren(int i, int j);
void swapChildrenInPlace(int i, int j);
protected:
/* Constructor */
@@ -115,12 +115,12 @@ protected:
/* Hierarchy operations */
// Add
virtual void addChildTreeAtIndex(TreeByReference t, int index, int currentNumberOfChildren);
virtual void addChildAtIndexInPlace(TreeByReference t, int index, int currentNumberOfChildren);
// Remove puts a child at the end of the pool
virtual void removeChildTreeAtIndex(int i);
virtual void removeChildTree(TreeByReference t, int childNumberOfChildren);
virtual void removeChildren(int currentNumberOfChildren);
virtual void removeChildrenAndDestroy(int currentNumberOfChildren);
virtual void removeChildAtIndexInPlace(int i);
virtual void removeChildInPlace(TreeByReference t, int childNumberOfChildren);
virtual void removeChildrenInPlace(int currentNumberOfChildren);
virtual void removeChildrenAndDestroyInPlace(int currentNumberOfChildren);
int m_identifier;
private:

View File

@@ -66,7 +66,7 @@ public:
if (!(node()->isAllocationFailure())) {
static_cast<VerticalOffsetLayoutNode *>(node())->setType(type);
}
replaceTreeChildAtIndex(0,l);
replaceChildAtIndexInPlace(0,l);
}
private:
VerticalOffsetLayoutRef() : LayoutReference(TreePool::sharedPool()->createTreeNode<VerticalOffsetLayoutNode>(), true) {}

View File

@@ -73,7 +73,7 @@ void BracketPairLayoutNode::moveCursorRight(LayoutCursor * cursor, bool * should
void BracketPairLayoutNode::deleteBeforeCursor(LayoutCursor * cursor) {
if (cursor->isEquivalentTo(LayoutCursor(childLayout(), LayoutCursor::Position::Left))) {
// Case: Left of the operand. Delete the layout, keep the operand.
LayoutRef(this).replaceWith(LayoutRef(childLayout()), cursor);
LayoutRef(this).replaceWithInPlace(LayoutRef(childLayout()), cursor);
// WARNING: do not call "this" afterwards
return;
}

View File

@@ -87,7 +87,7 @@ bool EmptyLayoutNode::willAddSibling(LayoutCursor * cursor, LayoutNode * sibling
thisRef.setColor(Color::Yellow);
return true;
} else {
thisRef.replaceWith(siblingRef, cursor);
thisRef.replaceWithInPlace(siblingRef, cursor);
// WARNING: do not call "this" afterwards
return false;
}

View File

@@ -100,7 +100,7 @@ void FractionLayoutNode::deleteBeforeCursor(LayoutCursor * cursor) {
if (numeratorLayout()->isEmpty() && denominatorLayout()->isEmpty()) {
/* Case: Numerator and denominator are empty. Move the cursor and replace
* the fraction with an empty layout. */
thisRef.replaceWith(EmptyLayoutRef(), cursor);
thisRef.replaceWithInPlace(EmptyLayoutRef(), cursor);
// WARNING: Do no use "this" afterwards
return;
}

View File

@@ -278,7 +278,7 @@ bool HorizontalLayoutNode::willReplaceChild(LayoutNode * oldChild, LayoutNode *
* a parent, replace this with the new empty layout. */
LayoutNode * p = parent();
if (p != nullptr) {
thisRef.replaceWith(newChild, cursor);
thisRef.replaceWithInPlace(newChild, cursor);
// WARNING: do not call "this" afterwards
return false;
}
@@ -374,7 +374,7 @@ void HorizontalLayoutRef::mergeChildrenAtIndex(HorizontalLayoutRef h, int index,
}
// Merge the horizontal layout
mergeTreeChildrenAtIndex(h, newIndex);
mergeChildrenAtIndexInPlace(h, newIndex);
if (cursor != nullptr) {
if (!isAllocationFailure()) {

View File

@@ -132,7 +132,7 @@ void IntegralLayoutNode::moveCursorDown(LayoutCursor * cursor, bool * shouldReco
void IntegralLayoutNode::deleteBeforeCursor(LayoutCursor * cursor) {
if (cursor->isEquivalentTo(LayoutCursor(integrandLayout(), LayoutCursor::Position::Left))) {
// Case: Left of the integrand. Delete the layout, keep the integrand.
LayoutRef(this).replaceWith(LayoutRef(integrandLayout()), cursor);
LayoutRef(this).replaceWithInPlace(LayoutRef(integrandLayout()), cursor);
// WARNING: Do not use "this" afterwards
return;
}

View File

@@ -222,7 +222,7 @@ void LayoutCursor::addLayoutAndMoveCursor(LayoutRef l) {
void LayoutCursor::clearLayout() {
LayoutRef rootLayoutR = m_layoutRef.root();
assert(rootLayoutR.isHorizontal());
rootLayoutR.removeChildren();
rootLayoutR.removeChildrenInPlace();
m_layoutRef = rootLayoutR;
}

View File

@@ -26,7 +26,7 @@ void LayoutReference::replaceChild(LayoutRef oldChild, LayoutRef newChild, Layou
if (!node()->willReplaceChild(oldChild.node(), newChild.node(), cursor, force)) {
return;
}
replaceTreeChild(oldChild, newChild);
replaceChildInPlace(oldChild, newChild);
if (cursor != nullptr) {
if (isAllocationFailure()) {
cursor->setLayoutReference(*this);
@@ -107,7 +107,7 @@ void LayoutReference::addChildAtIndex(LayoutRef l, int index, int currentNumberO
}
}
this->addChildTreeAtIndex(l, newIndex, newCurrentNumberOfChildren);
this->addChildAtIndexInPlace(l, newIndex, newCurrentNumberOfChildren);
if (cursor != nullptr) {
if (this->isAllocationFailure()) {
@@ -174,7 +174,7 @@ void LayoutReference::removeChild(LayoutRef l, LayoutCursor * cursor, bool force
}
assert(hasChild(l));
int index = indexOfChild(l);
removeChildTree(l, numberOfChildren());
removeChildInPlace(l, numberOfChildren());
if (cursor) {
if (index < numberOfChildren()) {
LayoutRef newCursorRef = childAtIndex(index);

View File

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

View File

@@ -139,7 +139,7 @@ void NthRootLayoutNode::deleteBeforeCursor(LayoutCursor * cursor) {
&& cursor->position() == LayoutCursor::Position::Left)
{
// Case: Left of the radicand. Delete the layout, keep the radicand.
NthRootLayoutRef(this).replaceWith(LayoutRef(radicandLayout()), cursor);
NthRootLayoutRef(this).replaceWithInPlace(LayoutRef(radicandLayout()), cursor);
// WARNING: Do not call "this" afterwards
return;
}

View File

@@ -119,7 +119,7 @@ void SequenceLayoutNode::moveCursorDown(LayoutCursor * cursor, bool * shouldReco
void SequenceLayoutNode::deleteBeforeCursor(LayoutCursor * cursor) {
if (cursor->isEquivalentTo(LayoutCursor(argumentLayout(), LayoutCursor::Position::Left))) {
// Case: Left of the argument. Delete the layout, keep the argument.
LayoutRef(this).replaceWith(LayoutRef(argumentLayout()), cursor);
LayoutRef(this).replaceWithInPlace(LayoutRef(argumentLayout()), cursor);
// WARNING: do not use "this" afterwards
return;
}

View File

@@ -30,22 +30,22 @@ TreeByReference TreeByReference::clone() const {
/* Hierarchy operations */
void TreeByReference::replaceWith(TreeByReference t) {
void TreeByReference::replaceWithInPlace(TreeByReference t) {
assert(isDefined());
TreeByReference p = parent();
if (p.isDefined()) {
p.replaceTreeChild(*this, t);
p.replaceChildInPlace(*this, t);
}
}
void TreeByReference::replaceTreeChild(TreeByReference oldChild, TreeByReference newChild) {
void TreeByReference::replaceChildInPlace(TreeByReference oldChild, TreeByReference newChild) {
if (oldChild == newChild) {
return;
}
assert(isDefined());
if (newChild.isAllocationFailure()) {
replaceWithAllocationFailure(numberOfChildren());
replaceWithAllocationFailureInPlace(numberOfChildren());
return;
}
@@ -62,7 +62,7 @@ void TreeByReference::replaceTreeChild(TreeByReference oldChild, TreeByReference
oldChild.node()->release(oldChild.numberOfChildren());
}
void TreeByReference::replaceWithAllocationFailure(int currentNumberOfChildren) {
void TreeByReference::replaceWithAllocationFailureInPlace(int currentNumberOfChildren) {
if (isAllocationFailure()) {
return;
}
@@ -74,7 +74,7 @@ void TreeByReference::replaceWithAllocationFailure(int currentNumberOfChildren)
TreeNode * staticAllocFailNode = node()->failedAllocationStaticNode();
// Release all children and delete the node in the pool
removeChildrenAndDestroy(currentNumberOfChildren);
removeChildrenAndDestroyInPlace(currentNumberOfChildren);
/* WARNING: If we called "p.decrementNumberOfChildren()" here, the number of
* children of the parent layout would be:
* -> numberOfChildren() for "dynamic trees" that have a m_numberOfChildren
@@ -97,7 +97,7 @@ void TreeByReference::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.addChildTreeAtIndex(TreeByReference(newAllocationFailureNode), indexInParentNode, p.numberOfChildren() - 1);
p.addChildAtIndexInPlace(TreeByReference(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. */
@@ -106,12 +106,12 @@ void TreeByReference::replaceWithAllocationFailure(int currentNumberOfChildren)
}
}
void TreeByReference::replaceChildWithGhost(TreeByReference t) {
void TreeByReference::replaceChildWithGhostInPlace(TreeByReference t) {
GhostReference ghost;
return replaceTreeChild(t, ghost);
return replaceChildInPlace(t, ghost);
}
void TreeByReference::mergeTreeChildrenAtIndex(TreeByReference t, int i) {
void TreeByReference::mergeChildrenAtIndexInPlace(TreeByReference t, int i) {
assert(i >= 0 && i <= numberOfChildren());
// Steal operands
int numberOfNewChildren = t.numberOfChildren();
@@ -123,12 +123,12 @@ void TreeByReference::mergeTreeChildrenAtIndex(TreeByReference t, int i) {
t.node()->eraseNumberOfChildren();
// If t is a child, remove it
if (node()->hasChild(t.node())) {
removeChildTree(t, 0);
removeChildInPlace(t, 0);
}
node()->incrementNumberOfChildren(numberOfNewChildren);
}
void TreeByReference::swapChildren(int i, int j) {
void TreeByReference::swapChildrenInPlace(int i, int j) {
assert(isDefined());
assert(i >= 0 && i < numberOfChildren());
assert(j >= 0 && j < numberOfChildren());
@@ -146,13 +146,13 @@ void TreeByReference::swapChildren(int i, int j) {
/* Protected */
// Add
void TreeByReference::addChildTreeAtIndex(TreeByReference t, int index, int currentNumberOfChildren) {
void TreeByReference::addChildAtIndexInPlace(TreeByReference t, int index, int currentNumberOfChildren) {
assert(isDefined());
if (node()->isAllocationFailure()) {
return;
}
if (t.isAllocationFailure()) {
replaceWithAllocationFailure(currentNumberOfChildren);
replaceWithAllocationFailureInPlace(currentNumberOfChildren);
return;
}
assert(index >= 0 && index <= currentNumberOfChildren);
@@ -170,21 +170,21 @@ void TreeByReference::addChildTreeAtIndex(TreeByReference t, int index, int curr
// Remove
void TreeByReference::removeChildTreeAtIndex(int i) {
void TreeByReference::removeChildAtIndexInPlace(int i) {
assert(isDefined());
assert(i >= 0 && i < numberOfChildren());
TreeByReference t = treeChildAtIndex(i);
removeChildTree(t, t.numberOfChildren());
removeChildInPlace(t, t.numberOfChildren());
}
void TreeByReference::removeChildTree(TreeByReference t, int childNumberOfChildren) {
void TreeByReference::removeChildInPlace(TreeByReference t, int childNumberOfChildren) {
assert(isDefined());
TreePool::sharedPool()->move(TreePool::sharedPool()->last(), t.node(), childNumberOfChildren);
t.node()->release(childNumberOfChildren);
node()->decrementNumberOfChildren();
}
void TreeByReference::removeChildren(int currentNumberOfChildren) {
void TreeByReference::removeChildrenInPlace(int currentNumberOfChildren) {
assert(isDefined());
for (int i = 0; i < currentNumberOfChildren; i++) {
TreeByReference childRef = treeChildAtIndex(0);
@@ -194,8 +194,8 @@ void TreeByReference::removeChildren(int currentNumberOfChildren) {
node()->eraseNumberOfChildren();
}
void TreeByReference::removeChildrenAndDestroy(int currentNumberOfChildren) {
removeChildren(currentNumberOfChildren);
void TreeByReference::removeChildrenAndDestroyInPlace(int currentNumberOfChildren) {
removeChildrenInPlace(currentNumberOfChildren);
TreePool::sharedPool()->discardTreeNode(node());
}
@@ -225,7 +225,7 @@ void TreeByReference::buildGhostChildren() {
// Add a ghost child
GhostReference ghost;
if (ghost.isAllocationFailure()) {
replaceWithAllocationFailure(numberOfChildren());
replaceWithAllocationFailureInPlace(numberOfChildren());
return;
}
TreePool::sharedPool()->move(node()->next(), ghost.node(), 0);

View File

@@ -18,7 +18,7 @@ void TreeNode::release(int currentNumberOfChildren) {
}
m_referenceCounter--;
if (m_referenceCounter == 0) {
TreeByReference(this).removeChildrenAndDestroy(currentNumberOfChildren);
TreeByReference(this).removeChildrenAndDestroyInPlace(currentNumberOfChildren);
}
}

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->addChildTreeAtIndex(leftPar, 0);
layout->addChildTreeAtIndex(new CharLayout('2'), 1);
layout->addChildTreeAtIndex(new CharLayout('+'), 2);
layout->addChildTreeAtIndex(new LeftParenthesisLayout(), 3);
layout->addChildTreeAtIndex(new FractionLayout(
layout->addChildAtIndexInPlace(leftPar, 0);
layout->addChildAtIndexInPlace(new CharLayout('2'), 1);
layout->addChildAtIndexInPlace(new CharLayout('+'), 2);
layout->addChildAtIndexInPlace(new LeftParenthesisLayout(), 3);
layout->addChildAtIndexInPlace(new FractionLayout(
new CharLayout('3'),
new CharLayout('4')),
4);
layout->addChildTreeAtIndex(new RightParenthesisLayout(), 3);
layout->addChildTreeAtIndex(new CharLayout('6'), 5);
layout->addChildTreeAtIndex(rightPar, 7);
layout->addChildTreeAtIndex(new CharLayout('1'), 8);
layout->addChildAtIndexInPlace(new RightParenthesisLayout(), 3);
layout->addChildAtIndexInPlace(new CharLayout('6'), 5);
layout->addChildAtIndexInPlace(rightPar, 7);
layout->addChildAtIndexInPlace(new CharLayout('1'), 8);
assert(leftPar->size().height() == rightPar->size().height());
delete layout;
}