AuD
Lecture 'Algorithmen und Datenstrukturen' (code examples)
aud.example.expr.AtomicExpression Class Referenceabstract

Superclass for data associated with a tree node. More...

+ Inheritance diagram for aud.example.expr.AtomicExpression:
+ Collaboration diagram for aud.example.expr.AtomicExpression:

Classes

enum  Type
 type identifiers returned by getType More...
 

Public Member Functions

boolean isOperator ()
 node represents operator More...
 
boolean isTerminal ()
 node represents number or symbol More...
 
abstract Type getType ()
 Get type identifier. More...
 
AtomicExpression clone ()
 Get a copy: a new AtomicExpression of same type/content. More...
 
abstract double getValue ()
 get value More...
 

Protected Attributes

ExpressionTree node_ = null
 uplink reference to node: node_.getData()==this @endiliteral
More...
 

Detailed Description

Superclass for data associated with a tree node.

See also
ExpressionTree

Definition at line 6 of file AtomicExpression.java.

Member Function Documentation

◆ clone()

AtomicExpression aud.example.expr.AtomicExpression.clone ( )

Get a copy: a new AtomicExpression of same type/content.

Reimplemented in aud.example.expr.Divide, aud.example.expr.Minus, aud.example.expr.Number, aud.example.expr.Plus, aud.example.expr.Symbol, aud.example.expr.Times, and aud.example.expr.UnaryMinus.

Definition at line 29 of file AtomicExpression.java.

29 {
30 // Note that this should be an abstract method!
31 //
32 // The implementation that throws an exception frees us from
33 // defining clone(), e.g., in the new Power class (expect less
34 // suprises.)
35 //
36 // Similarly, AtomicExpression should better implement
37 // Cloneable; but then we always had to take care of possible
38 // exception (CloneNotSupportedException).
39 throw new RuntimeException("You didn't overwrite clone()!");
40 }

◆ getType()

abstract Type aud.example.expr.AtomicExpression.getType ( )
abstract

◆ getValue()

abstract double aud.example.expr.AtomicExpression.getValue ( )
abstract

get value

Exceptions
UnsupportedOperationExceptionif value cannot be determined

Reimplemented in aud.example.expr.Divide, aud.example.expr.Minus, aud.example.expr.Number, aud.example.expr.Plus, aud.example.expr.Symbol, aud.example.expr.Times, and aud.example.expr.UnaryMinus.

◆ isOperator()

boolean aud.example.expr.AtomicExpression.isOperator ( )

node represents operator

Definition at line 16 of file AtomicExpression.java.

16{ return !isTerminal(); }
boolean isTerminal()
node represents number or symbol

References aud.example.expr.AtomicExpression.isTerminal().

+ Here is the call graph for this function:

◆ isTerminal()

boolean aud.example.expr.AtomicExpression.isTerminal ( )

node represents number or symbol

Definition at line 18 of file AtomicExpression.java.

18{ return node_.isLeaf(); }
boolean isLeaf()
Is this a leaf?
Definition: BinaryTree.java:96
ExpressionTree node_
uplink reference to node: node_.getData()==this @endiliteral

References aud.BinaryTree< T >.isLeaf(), and aud.example.expr.AtomicExpression.node_.

Referenced by aud.example.expr.AtomicExpression.isOperator().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Member Data Documentation

◆ node_

ExpressionTree aud.example.expr.AtomicExpression.node_ = null
protected

The documentation for this class was generated from the following file: