org.grinvin.engine.apengine

Class TreeGenerator

Known Direct Subclasses:
ExactTreeGenerator, LimitedTreeGenerator

public class TreeGenerator
extends java.lang.Object

Author:
adpeeter

Nested Class Summary

protected class
TreeGenerator.TreeGeneratorStateStack
Private class to represent the stack of the TreeGenerator.

Field Summary

protected boolean
completeWorkingTree
protected int
currentBinaryOperators
protected int
currentUnaryOperators
protected TreeGenerator.TreeGeneratorStateStack
stateStack
protected LabeledBinaryTree
workingTree

Constructor Summary

TreeGenerator()
TreeGenerator(int unaryOperators, int binaryOperators)

Method Summary

boolean
complete(LabeledBinaryTree tree)
Is the given LabeledBinaryTree complete? A tree is complete if its amount of unary and binary operators matches the current unary and binary operator count respectively.
boolean
correct(LabeledBinaryTree tree)
Is the given LabeledBinaryTree correct? A tree is correct if it is still possible to extend it to a complete tree.
protected void
extend()
Try to extend the workingTree.
LabeledBinaryTree
nextTree()
Return the next LabeledBinaryTree.
protected void
pushNextOperatorCount()
Push a new depthstate on the stack with the next number of unary and binary operators.

Field Details

completeWorkingTree

protected boolean completeWorkingTree

currentBinaryOperators

protected int currentBinaryOperators

currentUnaryOperators

protected int currentUnaryOperators

stateStack

protected TreeGenerator.TreeGeneratorStateStack stateStack

workingTree

protected LabeledBinaryTree workingTree

Constructor Details

TreeGenerator

public TreeGenerator()

TreeGenerator

public TreeGenerator(int unaryOperators,
                     int binaryOperators)

Method Details

complete

public boolean complete(LabeledBinaryTree tree)
Is the given LabeledBinaryTree complete? A tree is complete if its amount of unary and binary operators matches the current unary and binary operator count respectively.

correct

public boolean correct(LabeledBinaryTree tree)
Is the given LabeledBinaryTree correct? A tree is correct if it is still possible to extend it to a complete tree.

extend

protected void extend()
Try to extend the workingTree.

nextTree

public LabeledBinaryTree nextTree()
Return the next LabeledBinaryTree.

pushNextOperatorCount

protected void pushNextOperatorCount()
Push a new depthstate on the stack with the next number of unary and binary operators. The operators are added as follows:
unary
00
10
01
20
11
30
02