Java ArraryUnorderedList无法解析为类型

Java ArraryUnorderedList无法解析为类型,java,arrays,eclipse,arraylist,binary-tree,Java,Arrays,Eclipse,Arraylist,Binary Tree,我正在尝试使用数组实现生成二叉树。然而,在Eclipse中,我得到一个错误,说“ArrayUnorderedList无法解析为类型”。我不知道为什么我会收到这个错误。任何帮助都将不胜感激。当然,所有这些都是基于Java的。如果我需要更详细的说明,请告诉我 package jsjf; import java.util.*; import jsjf.exceptions.ElementNotFoundException; import jsjf.exceptions.EmptyCollection

我正在尝试使用数组实现生成二叉树。然而,在Eclipse中,我得到一个错误,说“ArrayUnorderedList无法解析为类型”。我不知道为什么我会收到这个错误。任何帮助都将不胜感激。当然,所有这些都是基于Java的。如果我需要更详细的说明,请告诉我

package jsjf;

import java.util.*;
import jsjf.exceptions.ElementNotFoundException;
import jsjf.exceptions.EmptyCollectionException;

public class ArrayCSBinaryTree<T> implements BinaryTreeADT<T>, Iterable<T> {
    private static final int DEFAULT_CAPACITY = 50;

    protected BinaryTreeNode<T> root; 
    protected int count;
    protected T[] tree;
    protected int modCount;

    @SuppressWarnings("unchecked")
    public ArrayCSBinaryTree() {
    root = null;
    count = 0;
    tree = (T[]) new Object[DEFAULT_CAPACITY];
    }

    public ArrayCSBinaryTree(T element) 
    {
        root = new BinaryTreeNode<T>(element);
    }

    @SuppressWarnings("unchecked")
    public ArrayCSBinaryTree(T element, ArrayCSBinaryTree<T> left, 
            ArrayCSBinaryTree<T> right) {

        root = new BinaryTreeNode<T>(element);
        root.setLeft(left.root);
        root.setRight(right.root);
        count = 1;
        tree = (T[]) new Object[DEFAULT_CAPACITY];
        tree[0] = element;
    }

    protected void expandCapacity() {
        tree = Arrays.copyOf(tree, tree.length * 2);
    }

    public T getRootElement() throws EmptyCollectionException {
        if (isEmpty())
            throw new EmptyCollectionException("ArrayBinaryTree");

        return tree[0];
    }

    public boolean isEmpty() {
        return (count == 0);
    }

    public int size() {
        return count;
    }

    public int getHeight() {
        return height(root);
    }

    private int height(BinaryTreeNode<T> node) {
        if (node == null) {
            return 0;
        } else {
            int leftHeight = height(node.getLeft());
            int rightHeight = height(node.getRight());
            return (1 + Math.max(leftHeight, rightHeight));
        }
    }

    public boolean contains(T targetElement) {
        T temp;
        boolean found = false;

        try {
            temp = find(targetElement);
            found = true;
        } catch (Exception ElementNotFoundException) {
            found = false;
        }

        return found;
    }

    public T find(T targetElement) throws ElementNotFoundException {
        T temp = null;
        boolean found = false;

        for (int i = 0; i < tree.length && !found; i++)
            if (tree[i] != null)
                if (targetElement.equals(tree[i])) {
                    found = true;
                    temp = tree[i];
                }

        if (!found)
            throw new ElementNotFoundException("ArrayCSBinaryTree");

        return temp;
    }

    public String toString() {
        ArrayUnorderedList<T> templist = new ArrayUnorderedList<T>();
        inOrder(0, templist);

        return templist.toString();
    }

    public Iterator<T> iterator() {
        return this.iteratorInOrder();
    }

    public Iterator<T> iteratorInOrder() {
        ArrayUnorderedList<T> templist = new ArrayUnorderedList<T>();
        inOrder(0, templist);

        return new TreeIterator(templist.iterator());
    }

    protected void inOrder(int node, ArrayUnorderedList<T> templist) {
        if (node < tree.length)
            if (tree[node] != null) {
                inOrder(node * 2 + 1, templist);
                templist.addToRear(tree[node]);
                inOrder((node + 1) * 2, templist);
            }
    }

    public Iterator<T> iteratorPreOrder() {
        ArrayUnorderedList<T> templist = new ArrayUnorderedList<T>();
        preOrder(0, templist);

        return new TreeIterator(templist.iterator());
    }

    protected void preOrder(int node, ArrayUnorderedList<T> templist) {
        if (node < tree.length)
            if (tree[node] != null) {
                templist.addToRear(tree[node]);
                preOrder(node * 2 + 1, templist);
                preOrder((node + 1) * 2, templist);
            }
    }

    public Iterator<T> iteratorPostOrder() {
        ArrayUnorderedList<T> templist = new ArrayUnorderedList<T>();
        postOrder(0, templist);

        return new TreeIterator(templist.iterator());
    }

    protected void postOrder(int node, ArrayUnorderedList<T> templist) {
        if (node < tree.length)
            if (tree[node] != null) {
                postOrder(node * 2 + 1, templist);
                postOrder((node + 1) * 2, templist);
                templist.addToRear(tree[node]);
            }
    }

    public Iterator<T> iteratorLevelOrder() {
        ArrayUnorderedList<T> templist = new ArrayUnorderedList<T>();
        int ct = 0;
        int i = 0;

        while (ct < count) {
            if (tree[i] != null) {
                templist.addToRear(tree[i]);
                ct++;
            }
            i++;
        }

        return new TreeIterator(templist.iterator());
    }

    private class TreeIterator implements Iterator<T> {
        private int expectedModCount;
        private Iterator<T> iter;

        public TreeIterator(Iterator<T> iter) {
            this.iter = iter;
            expectedModCount = modCount;
        }

        public boolean hasNext() throws ConcurrentModificationException {
            if (!(modCount == expectedModCount))
                throw new ConcurrentModificationException();

            return (iter.hasNext());
        }

        public T next() throws NoSuchElementException {
            if (hasNext())
                return (iter.next());
            else
                throw new NoSuchElementException();
        }

        public void remove() {
            throw new UnsupportedOperationException();
        }
    }
}
包jsjf;
导入java.util.*;
导入jsjf.exceptions.ElementNotFoundException;
导入jsjf.exceptions.EmptyCollectionException;
公共类ArrayCSBinaryTree实现BinaryTreeADT,Iterable{
专用静态最终int默认_容量=50;
受保护的金钱草根;
保护整数计数;
保护T[]树;
受保护的整数模计数;
@抑制警告(“未选中”)
公共ArrayCSBinaryTree(){
root=null;
计数=0;
tree=(T[])新对象[默认容量];
}
公共阵列SBinaryTree(T元素)
{
根=新的二元树烯(元素);
}
@抑制警告(“未选中”)
公共ArrayCSBinaryTree(T元素,ArrayCSBinaryTree左,
ArrayCSBinaryTree(右){
根=新的二元树烯(元素);
root.setLeft(left.root);
root.setRight(right.root);
计数=1;
tree=(T[])新对象[默认容量];
树[0]=元素;
}
受保护的空容量(){
tree=Arrays.copyOf(tree,tree.length*2);
}
public T getRootElement()引发EmptyCollectionException异常{
if(isEmpty())
抛出新的EmptyCollectionException(“ArrayBinaryTree”);
返回树[0];
}
公共布尔值为空(){
返回(计数=0);
}
公共整数大小(){
返回计数;
}
公共整数getHeight(){
返回高度(根);
}
专用整数高度(二进制树节点){
if(node==null){
返回0;
}否则{
int leftHeight=height(node.getLeft());
int rightHeight=高度(node.getRight());
返回值(1+数学最大值(leftHeight,rightHeight));
}
}
公共布尔包含(T targetElement){
温度;
布尔值=false;
试一试{
温度=查找(目标元素);
发现=真;
}捕获(异常元素NotFoundException){
发现=错误;
}
发现退货;
}
公共T find(T targetElement)抛出ElementNotFoundException{
温度=零;
布尔值=false;
对于(int i=0;i
你有没有在任何地方定义过
ArrayUnorderedList
类?我不这么认为。编辑:这段代码的大部分与我之前创建的链接二叉树类非常相似。我不知道