org.grinvin.conjecture.engine.apengine

Class TreeGenerator<T,extends,BinaryTree>

Known Direct Subclasses:
ExactTreeGenerator<T,extends,BinaryTree>, LimitedTreeGenerator<T,extends,BinaryTree>

public class TreeGenerator<T,extends,BinaryTree>
extends java.lang.Object

Author:
adpeeter

Nested Class Summary

protected static 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 TreeFactory
treeFactory
protected T
workingTree

Constructor Summary

TreeGenerator(TreeFactory treeFactory)
TreeGenerator(int unaryOperators, int binaryOperators, TreeFactory treeFactory)

Method Summary

boolean
complete(T 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(T 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.
T
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

treeFactory

protected TreeFactory treeFactory

workingTree

protected T workingTree

Constructor Details

TreeGenerator

public TreeGenerator(TreeFactory treeFactory)

TreeGenerator

public TreeGenerator(int unaryOperators,
                     int binaryOperators,
                     TreeFactory treeFactory)

Method Details

complete

public boolean complete(T 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(T 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 T nextTree()

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