Class TreeIterator<T>

java.lang.Object
  extended by TreeIterator<T>
All Implemented Interfaces:
java.util.Iterator<T>

public class TreeIterator<T>
extends java.lang.Object
implements java.util.Iterator<T>


Constructor Summary
TreeIterator(BinaryTreeBasis<T> bTree)
          This is the constructor for the TreeIterator.
 
Method Summary
 boolean hasNext()
          This method is used to verify that the TreeIterator has more elements to return.
 T next()
          This method is used to retrieve the next element from the TreeIterator.
 void remove()
          This method is not supported in the TreeIterator.
 void setInorder()
          This method sets the order of retrieval from the TreeIterator to be Inorder.
 void setPostorder()
          This method sets the order of retrieval from the TreeIterator to be Postorder.
 void setPreorder()
          This method sets the order of retrieval from the TreeIterator to be Preorder.
 int size()
          This method is used to obtain the number of elements available in the iterator.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TreeIterator

public TreeIterator(BinaryTreeBasis<T> bTree)
This is the constructor for the TreeIterator.

Parameters:
bTree - The BinaryTreeBasis that this iterator will operate on.
Method Detail

size

public int size()
This method is used to obtain the number of elements available in the iterator.

Returns:
Returns the number of TreeNode's available in the iterator.

hasNext

public boolean hasNext()
This method is used to verify that the TreeIterator has more elements to return.

Specified by:
hasNext in interface java.util.Iterator<T>
Returns:
Returns true if there are more elements to return, false otherwise.

next

public T next()
       throws java.util.NoSuchElementException
This method is used to retrieve the next element from the TreeIterator.

Specified by:
next in interface java.util.Iterator<T>
Returns:
Returns the next element from the TreeIterator.
Throws:
java.util.NoSuchElementException

remove

public void remove()
            throws java.lang.UnsupportedOperationException
This method is not supported in the TreeIterator.

Specified by:
remove in interface java.util.Iterator<T>
Throws:
This - method will always throw a UnsupportedOperationException
java.lang.UnsupportedOperationException

setPreorder

public void setPreorder()
This method sets the order of retrieval from the TreeIterator to be Preorder. This method will call the private method preorder() in order to populate the queue.


setInorder

public void setInorder()
This method sets the order of retrieval from the TreeIterator to be Inorder. This method will call the private method inorder() in order to populate the queue.


setPostorder

public void setPostorder()
This method sets the order of retrieval from the TreeIterator to be Postorder. This method will call the private method postorder() in order to populate the queue.