我目前有這個,但我想把我的列表變成一個雙鏈表,並且無法解決如何操作。爲雙鏈表添加節點方法?
public void addDNode(DNode v)
{
if(header == tail)
{
header = v;
}
else
{
DNode current = header;
while (current.nextNode() != null)
{
current = current.nextNode();
}
current.setNext(v);
}
}
java.util.LinkedList是雙鏈表。難道你不想使用它,或只是看看裏面的add()方法? – korifey
解決所有鏈表問題的方法是繪製圖表。這將幫助您精確地建立需要更新的指針/引用數量。 –
@ user979236:那你是怎麼寫這段代碼的? –