我的问题是如何将一个List添加到DLL(双向链表)
@Override
public boolean addAll(List<? extends E> toAdd) throws NullPointerException
{
DLLNode<E> dll = new DLLNode<E>(toAdd);
for(int i = 1; i < toAdd.size(); i++)
{
head = (DLLNode) toAdd.get(1);
}
}
DLLNode是用于创建双向链表的类。
public class DLLNode<E>
{
protected E element;
protected List<? extends E> newElement;
protected DLLNode prev;
protected DLLNode next;
public DLLNode(E toAdd)
{
this.element = toAdd;
}
public DLLNode(List<? extends E> toAdd)
{
this.newElement = toAdd;
}
}
下一位是来自JUnitTest的代码。我将继续在互联网上阅读,但我真的无法弄清楚这一点。
@Test
public <E> void testAddAllDLL()
{
E temp, temp1;
temp = (E) "Hello";
temp1 = (E) "Hello again";
DLL<E> list = new DLL<E>();
DLL<E> addList = new DLL<E>();
addList.add(temp);
addList.add(temp1);
list.addAll(addList);
list.iterator();
}
list.addAll(addList);不起作用,我尝试了很多不同的方法。感谢您阅读...