de.init.its.simplemodel
Class BaseTree<T>

java.lang.Object
  extended by de.init.its.simplemodel.BaseTree<T>
Type Parameters:
T -

public class BaseTree<T>
extends java.lang.Object

Simple tree implementation

Author:
mkandora

Field Summary
protected  java.util.List<BaseTree<T>> children
           
protected static java.lang.String EOL
           
protected  T head
           
protected  java.util.Map<T,BaseTree<T>> mapping
           
protected  BaseTree<T> parent
           
 
Constructor Summary
BaseTree()
           
BaseTree(T head)
          Creates a new Tree with an head element
 
Method Summary
 java.util.List<BaseTree<T>> getChildren()
          Returns the children of this node
 T getHead()
          Returns the head of this node
 BaseTree<T> getParent()
          Returns the parent of this node
 java.util.Collection<T> getSuccessors()
          returns the successive elements of this node
 java.util.Collection<T> getSuccessors(T root)
          returns the successors ofthe root element
 boolean hasChildren()
          Returns true, if this subtree contains children
 BaseTree<T> insert(T node)
          Inserts an element as child to this tree and returns the child subtree
 BaseTree<T> insert(T parent, T node)
          Inserts an element as child for the parent and returns the child subtree
 java.lang.String print()
          prints the tree
 BaseTree<T> remove(T node)
          Removes a node form the tree and returns the subtree
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

EOL

protected static final java.lang.String EOL

parent

protected BaseTree<T> parent

head

protected T head

children

protected java.util.List<BaseTree<T>> children

mapping

protected java.util.Map<T,BaseTree<T>> mapping
Constructor Detail

BaseTree

public BaseTree(T head)
Creates a new Tree with an head element

Parameters:
head -

BaseTree

public BaseTree()
Method Detail

insert

public BaseTree<T> insert(T parent,
                          T node)
Inserts an element as child for the parent and returns the child subtree

Parameters:
parent -
node -
Returns:

insert

public BaseTree<T> insert(T node)
Inserts an element as child to this tree and returns the child subtree

Parameters:
node -
Returns:

remove

public BaseTree<T> remove(T node)
Removes a node form the tree and returns the subtree

Parameters:
node -
Returns:

getHead

public T getHead()
Returns the head of this node

Returns:

getParent

public BaseTree<T> getParent()
Returns the parent of this node

Returns:

getChildren

public java.util.List<BaseTree<T>> getChildren()
Returns the children of this node

Returns:

hasChildren

public boolean hasChildren()
Returns true, if this subtree contains children

Returns:

getSuccessors

public java.util.Collection<T> getSuccessors()
returns the successive elements of this node

Returns:

getSuccessors

public java.util.Collection<T> getSuccessors(T root)
returns the successors ofthe root element

Parameters:
root -
Returns:

print

public java.lang.String print()
prints the tree

Returns: