初始化DListNode

时间:2014-04-08 04:54:44

标签: java linked-list

当我定义DListNode时,我需要三个变量。我无法弄清楚哪些是哪个。

DListNode doubleCur = new DListNode(var1,var2,var3);

每个var对应什么? (我知道一个是节点,另外两个是链接,但我在哪个顺序定义它们?)

1 个答案:

答案 0 :(得分:0)

DListNode是一个自定义类,因此它取决于它的实现方式。

无论如何,下面怎么样?

...
...
...
public Object item;
protected DListNode prev;
protected DListNode next;

/**
 *  DListNode() constructor.
 *  @param i the item to store in the node.
 *  @param p the node previous to this node.
 *  @param n the node following this node.
 */

DListNode(Object i, DListNode p, DListNode n) {
   item = i;
   prev = p;
   next = n;
}

寻找" DListNode"在Google上,第一和第二个结果已经提供了选项;)