com.discoversites.util.collections.tree
Interface Tree<T>

Type Parameters:
T - The type of element to be stored in the Tree
All Superinterfaces:
Iterable<T>, Serializable
All Known Implementing Classes:
ArrayTree, SetTree

public interface Tree<T>
extends Iterable<T>, Serializable

This interface is meant to provide a template for the creation of classes that implement an unordered tree data structure. The main goal of this interface is to provide a tree datastructure to complement the Java Collections API.

This project started as a way to store generic objects that need to be stored in a hierarchical manner for later presentation in a tree format in a UI. An example of this would be a drop down menu system on a web site that can be of variable depth.

Author:
Mark

Method Summary
 int depth()
           
 Collection<T> getBreadthFirstElements()
           
 Collection<TreeNode<T>> getBreadthFirstNodes()
           
 Collection<T> getDepthFirstElements()
           
 Collection<TreeNode<T>> getDepthFirstNodes()
           
 Collection<T> getElements()
           
 Collection<TreeNode<T>> getNodes()
           
 TreeRoot<T> getRoot()
           
 Iterator<T> iterator()
           
 Iterator<TreeNode<T>> nodeIterator()
           
 int size()
           
 

Method Detail

getRoot

TreeRoot<T> getRoot()
Returns:
The root node of the tree

iterator

Iterator<T> iterator()
Specified by:
iterator in interface Iterable<T>
Returns:
An Iterator that iterates over the elements stored in the tree's nodes. The order the elements are returned is not gauranteed by this method.

nodeIterator

Iterator<TreeNode<T>> nodeIterator()
Returns:
An Iterator that iterates over the tree's nodes. The order the nodes are returned is not gauranteed by this method.

getBreadthFirstElements

Collection<T> getBreadthFirstElements()
Returns:
An Collection that contains the elements stored in the tree's nodes. The elements are returned in breadth first order.

getBreadthFirstNodes

Collection<TreeNode<T>> getBreadthFirstNodes()
Returns:
An Collection that contains the tree's nodes. The nodes are returned in breadth first order.

getDepthFirstElements

Collection<T> getDepthFirstElements()
Returns:
An Collection that contains the elements stored in the tree's nodes. The elements are returned in depth first order.

getDepthFirstNodes

Collection<TreeNode<T>> getDepthFirstNodes()
Returns:
An Collection that contains the tree's nodes. The nodes are returned in depth first order.

getElements

Collection<T> getElements()
Returns:
A Collection of all the elements in the tree. The order of the elements is not gauranteed by this method.

getNodes

Collection<TreeNode<T>> getNodes()
Returns:
A Collection of all nodes in the tree. The order of the nodes is not gauranteed by this method.

size

int size()
Returns:
The number of elements in the tree.

depth

int depth()
Returns:
The depth of the tree, i.e. the number of levels the tree has.