![]() |
AuD
Lecture 'Algorithmen und Datenstrukturen' (code examples)
|
Tree representation of arithmetic expression. More...
Public Member Functions | |
ExpressionTree (AtomicExpression atom, ExpressionTree left, ExpressionTree right) | |
creare and link tree node More... | |
ExpressionTree (AtomicExpression atom) | |
create tree node More... | |
double | getValue () |
compute value of expression More... | |
void | setData (AtomicExpression data) |
Set AtomicExpression for this node. More... | |
String | toString () |
Get string presentation of node data. More... | |
GraphvizDecorator | getDecorator () |
get decoration or null More... | |
![]() | |
BinaryTree (T data) | |
create new root node without children More... | |
BinaryTree (T data, BinaryTree< T > left, BinaryTree< T > right) | |
create new root node with children More... | |
BinaryTree< T > | setLeft (BinaryTree< T > tree) |
set left subtree More... | |
BinaryTree< T > | setRight (BinaryTree< T > tree) |
set right subtree More... | |
void | setData (T data) |
set node data More... | |
T | getData () |
get node data More... | |
BinaryTree< T > | getParent () |
get node's parent or null for root More... | |
BinaryTree< T > | getLeft () |
get left child or null More... | |
BinaryTree< T > | getRight () |
get right child or null ) More... | |
boolean | isRoot () |
Iscode this} root? More... | |
boolean | isLeaf () |
Is this a leaf? More... | |
BinaryTree< T > | getRoot () |
traverse upwards to find root node More... | |
BinaryTreeTraversal< T >.Preorder | preorder () |
Get preorder iterator over nodes in tree . More... | |
BinaryTreeTraversal< T >.Inorder | inorder () |
Get inorder iterator over nodes in tree . More... | |
BinaryTreeTraversal< T >.Postorder | postorder () |
Get postorder iterator over nodes in tree . More... | |
BinaryTreeTraversal< T >.Levelorder | levelorder () |
Get level-order iterator over nodes in tree . More... | |
String | toDot () |
Get dot representation. More... | |
String | toText () |
get multiline text visualization More... | |
String | toTikZ () |
get TikZ code for LaTeX export More... | |
String | toDot () |
Get dot representation. More... | |
GraphvizDecorator | getDecorator () |
get decoration or null More... | |
Static Public Member Functions | |
static void | main (String[] args) |
test and example for usage More... | |
![]() |
Additional Inherited Members | |
![]() | |
String | dotLabel () |
String | textLabel () |
Get string representation of data in toText . More... | |
String | tikzNodeStyle () |
String | toTikZ (int level) |
Tree representation of arithmetic expression.
Each node is associated with an AtomicExpression
, which can be either an Terminal
or an Operator
.
Definition at line 14 of file ExpressionTree.java.
aud.example.expr.ExpressionTree.ExpressionTree | ( | AtomicExpression | atom, |
ExpressionTree | left, | ||
ExpressionTree | right | ||
) |
creare and link tree node
Definition at line 16 of file ExpressionTree.java.
References aud.example.expr.AtomicExpression.node_.
create tree node
Definition at line 25 of file ExpressionTree.java.
GraphvizDecorator aud.example.expr.ExpressionTree.getDecorator | ( | ) |
get decoration or null
Reimplemented from aud.BinaryTree< T >.
Definition at line 70 of file ExpressionTree.java.
Referenced by aud.example.expr.ExpressionTreeTraversal.ExpressionTreeTraversal().
double aud.example.expr.ExpressionTree.getValue | ( | ) |
compute value of expression
UnsupportedOperationException | if value cannot be determined |
getData()
Definition at line 34 of file ExpressionTree.java.
References aud.BinaryTree< T >.getData().
Referenced by aud.example.expr.ExpressionTree.main(), and aud.example.expr.ExpressionTreeExample.main().
|
static |
test and example for usage
Reimplemented from aud.BinaryTree< T >.
Definition at line 76 of file ExpressionTree.java.
References aud.example.expr.ExpressionTree.getValue(), aud.BinaryTree< T >.postorder(), and aud.BinaryTreeTraversal< T >.Traversal.toString().
void aud.example.expr.ExpressionTree.setData | ( | AtomicExpression | data | ) |
Set AtomicExpression
for this node.
Applies missing "uplink" to node for, i.e., this method manipulates its argument!
For this reason prefer constructing a new node/tree!
Definition at line 43 of file ExpressionTree.java.
References aud.example.expr.AtomicExpression.node_.
String aud.example.expr.ExpressionTree.toString | ( | ) |
Get string presentation of node data.
This method only encodes the node's content as string, it does not encode the entire tree! (This makes it easier to, e.g., print out a Stack
of nodes.)
getData
.toString
Reimplemented from aud.BinaryTree< T >.
Definition at line 51 of file ExpressionTree.java.
References aud.BinaryTree< T >.getData(), aud.BinaryTree< T >.getLeft(), aud.BinaryTree< T >.getRight(), aud.BinaryTree< T >.isLeaf(), and aud.BinaryTree< T >.isRoot().