this is what my assignment requires of me:
Requirement #2: Implementthe java.util.IteratorInterface
The java.util.Iterator interfaceis defined on-line at java.sun.com.You must implementan Iterator thatwill iterate over the items stored in your AVL tree. You couldimplement your Iterator using aclass that is nested inside of the class you use toimplementjava.util.Set.
You must fully implement the following methods:
boolean hasNext()
Object next()
Your implementation is allowed to throw UnsupportedOperationException for thefollowing method:
void remove()
Your implementation must conform to the required behavior ofeach method as defined in the on-line documentation. The definitionof java.util.Set allows anIteratorto return the items in theset in any order. Your implementation must meet an additionalrequirement. You must return the items in the order given by apreordertraversal of the AVL tree that is implementing theset. The order in which items are returned from the Iterator will be used to determine if yourtree isconstructed and balanced correctly.
The iterator method in the classthat implements java.util.Setshould return an Iterator object asdescribed in this section.
The toArray method in the classthat implements java.util.Set mustfill its array in the same order as described here for theIterator. In fact, you could useanIterator to help implement the toArray method.
--------------------------------------------------------------------------------------------------------
this is what I have so far the metho and the class are all nestedinside TreeImpl.java, may need some fixing and some implementation,any help would beappreciated:
public Iterator iterator() {
// TODOAuto-generated method stub
IteratorImpliter = new IteratorImpl();
return iter;
}
public class IteratorImplimplements java.util.Iterator<Object>{
publicIteratorImpl()
{
TreeImpl tree = new TreeImpl();
tree.iterator();
}
publicboolean hasNext() {
// TODO Auto-generated method stub
return false;
}
publicObject next() {
// TODO Auto-generated method stub
return null;
}
publicvoid remove() {
// TODO Auto-generated method stub
throw newUnsupportedOperationException();
}
}