public class ExpressionTreeElement extends Object
Modifier and Type | Field and Description |
---|---|
static ExpressionTreeElement |
EMPTY_SLOT |
Modifier and Type | Method and Description |
---|---|
ExpressionTreeElement |
addSubTree(ExpressionTree tree)
Add a tree as new child and make the maximum priority for it
|
ExpressionTreeElement |
addTreeElement(ExpressionTreeElement element)
Add tree element with sorting operation depends on priority of the elements
|
void |
fillArguments(List<ExpressionTree> arguments)
It fills children slots from a list containing expression trees
|
int |
getArity()
Get arity for the element (I mean possible children number)
|
ExpressionTreeElement |
getChildForIndex(int index)
Get the child element for its index (the first is 0)
|
ExpressionItem |
getItem()
Get the wrapped item
|
ExpressionTreeElement |
getParent()
Get the parent for the element
|
int |
getPriority()
Get the current priority of the element
|
boolean |
isEmptySlot()
Allows to check that the element is EMPTY_SLOT
|
boolean |
isFull()
It allows to check that all children slots have been filled
|
void |
postProcess()
Post-processing after the tree is formed, the unary minus operation will be optimized
|
boolean |
replaceElement(ExpressionTreeElement oldOne,
ExpressionTreeElement newOne)
It replaces a child element
|
public static final ExpressionTreeElement EMPTY_SLOT
public boolean isEmptySlot()
public ExpressionItem getItem()
public int getArity()
public ExpressionTreeElement getParent()
public int getPriority()
public ExpressionTreeElement addSubTree(ExpressionTree tree)
tree
- a tree to be added as a child, must not be nullpublic boolean replaceElement(ExpressionTreeElement oldOne, ExpressionTreeElement newOne)
oldOne
- the old expression element to be replaced (must not be null)newOne
- the new expression element to be used instead the old one (must not be null)public ExpressionTreeElement getChildForIndex(int index)
index
- the index of the needed childArrayIndexOutOfBoundsException
- it will be thrown if an impossible index is being usedEMPTY_SLOT
public ExpressionTreeElement addTreeElement(ExpressionTreeElement element)
element
- the element to be added, must not be nullpublic boolean isFull()
public void fillArguments(@MustNotContainNull List<ExpressionTree> arguments)
arguments
- the list containing trees to be used as childrenpublic void postProcess()
Copyright © 2011–2020 Igor Maznitsa. All rights reserved.