链中包含LinkedList的元素。 注意:此类的操作管理链接与其邻居之间的关系。 LinkedList负责保持列表的首尾。需要帮助了解java链接列表putAfter()方法
public class Link<Item> {
private final Item item;
private Link<Item> next;
private Link<Item> prev;
将此链接插入给定链接后的列表中。 @param之前是给定的链接。
public final void putAfter (Link<Item> before) {
prev = before;
if (null == before) return;
next = before.next;
before.next = this;
if (null != next)
next.prev = this;
}
此代码不起作用 - 您测试了吗? (提示:你需要'while()'loop) – alfasin 2013-02-23 01:25:07
是的,它确实有效。 – 2013-02-23 02:29:06