Java 泛型二叉搜索树的迭代器实现

Java 泛型二叉搜索树的迭代器实现,java,generics,iterator,binary-search-tree,Java,Generics,Iterator,Binary Search Tree,我对如何为这个特定的通用bst实现迭代器有点困惑,我正在为它实现迭代器。下面是一些代码: public class BinSearchTree<E extends Comparable<E>> extends AbstractSet<E> { protected Entry<E> root; protected int size; public BinSearchTree() { root = null; size = 0; } p

我对如何为这个特定的通用bst实现迭代器有点困惑,我正在为它实现迭代器。下面是一些代码:

public class BinSearchTree<E extends Comparable<E>> extends AbstractSet<E> {
protected Entry<E> root;
protected int size;
public BinSearchTree() {
    root = null;
    size = 0;
}
public BinSearchTree(BinSearchTree<E> otherTree) {

    LinkedList<Entry <E>> elements= new LinkedList<Entry<E>>();
    elements.add(otherTree.root);
    while(!elements.isEmpty()){
        BinSearchTree.add(elements.remove());
    }

}
公共类BinSearchTree扩展了抽象集{
受保护的入口根;
保护整数大小;
公共BinSearchTree(){
root=null;
尺寸=0;
}
公共BinSearchTree(BinSearchTree其他树){
LinkedList元素=新LinkedList();
添加(otherTree.root);
而(!elements.isEmpty()){
添加(elements.remove());
}
}
下面是我必须实现的大致内容

 protected class TreeIterator implements Iterator<E> {



    /**
     * Positions this TreeIterator to the smallest
     * element, according to the Comparable interface,
     * in the BST object.  The worstTime(n) is O(n)
     * and averageTime(n) is O(log n).
     */
    protected TreeIterator() {

    }

    /**
     * Determines if there are still some elements,
     * in the BST object this TreeIterator object is
     * iterating over, that have not been accessed by
     * this TreeIterator object.
     *
     * @return true - if there are still some elements
     *         that have not been accessed by this
     *         TreeIterator object; otherwise, return
     *         false.
     */ 
    public boolean hasNext() {
        return false;

    }

    /**
     * Returns the element in the Entry this
     * TreeIterator object was positioned at 
     * before this call, and advances this 
     * TreeIterator object.  The worstTime(n) is O(n)
     * and averageTime(n) is constant.
     *
     * @return the element this TreeIterator object
     *         was positioned at before this call.
     *
     * @throws NoSuchElementException - if this 
     *         TreeIterator object was not positioned
     *         at an Entry before this call.
     */
    public E next() {
        return null;   

    }

    /**
     * Removes the element returned by the most recent
     * call to this TreeIterator object’s next() method.
     * The worstTime(n) is O(n) and averageTime(n) is
     * constant.
     *
     * @throws IllegalStateException - if this 
     *         TreeIterator’s next() method was not
     *         called before this call, or if this 
     *         TreeIterator’s remove() method was called
     *         between the call to the next() method and
     *         this call.
     */ 
    public void remove() {


    }
}
受保护类树编辑器实现迭代器{
/**
*将此树运算符定位到最小值
*元素,根据可比界面,
*在BST对象中。最短时间(n)为O(n)
*平均时间(n)是O(logn)。
*/
受保护的树运算符(){
}
/**
*确定是否仍存在某些元素,
*在BST对象中,此TreeIterator对象是
*在上迭代,但未被访问
*这是一个树运算符对象。
*
*@return true-如果还有一些元素
*此服务器尚未访问的
*TreeIterator对象;否则,返回
*错。
*/ 
公共布尔hasNext(){
返回false;
}
/**
*返回此项中的元素
*TreeIterator对象定位在
*在此呼叫之前,并提前此
*树运算符对象。最短时间(n)为O(n)
*平均时间(n)是常数。
*
*@返回此TreeIterator对象的元素
*在此呼叫之前已定位在。
*
*@抛出NoTouchElementException-如果
*未定位TreeIterator对象
*在本次通话前的一个入口。
*/
公共教育{
返回null;
}
/**
*删除由最近的
*调用此树运算符对象的next()方法。
*最短时间(n)为O(n),平均时间(n)为
*不变的。
*
*@抛出非法状态异常-如果
*TreeIterator的next()方法不可用
*在此呼叫之前呼叫,或者如果
*调用了TreeIterator的remove()方法
*在调用next()方法和
*这个电话。
*/ 
公共空间删除(){
}
}

欢迎提供任何帮助,谢谢!

我投票将此问题作为离题题题结束,因为堆栈溢出不是代码编写服务。请说明您尝试了什么以及遇到了什么问题。对于BST遍历,有一个众所周知的算法:我不懂这行:
BinSearchTree.add(elements.remove())
您正在调用一个静态方法
add