dnode-node.html

来自「经典的数据结构源代码(java 实现)」· HTML 代码 · 共 36 行

HTML
36
字号
<html><head><title>Code Fragment</title></head><body text=#000000><center></center><br><br><dl><dd><pre><font color = #ff0080>/** Node of a doubly linked list of strings */</font><font color=#8000a0>public</font> <font color=#8000a0><font color=#ff8000>class</font> </font>DNode {  <font color=#8000a0><font color=#8000a0>protected</font> </font><font color=#8000a0>String</font> element;	<font color=#ff0080>// String element stored by a node</font>  <font color=#8000a0><font color=#8000a0>protected</font> </font>DNode next, prev;	<font color=#ff0080>// Pointers to next and previous nodes</font>  <font color = #ff0080>/** Constructor that creates a node with given fields */</font>  <font color=#8000a0><font color=#8000a0>public</font> </font><font color=#0000ff>DNode</font>(<font color=#8000a0>String</font> e, <font color=#8000a0>DNode </font>p, <font color=#8000a0>DNode </font>n) {    element = e;    prev = p;    next = n;  }  <font color = #ff0080>/** Returns the element of this node */</font>  <font color=#8000a0><font color=#8000a0>public</font> </font><font color=#8000a0>String</font> <font color=#0000ff>getElement</font>() { <font color=#8000a0><font color=#ff8000>return</font> </font>element; }  <font color = #ff0080>/** Returns the previous node of this node */</font>  <font color=#8000a0><font color=#8000a0>public</font> </font>DNode <font color=#0000ff>getPrev</font>() { <font color=#8000a0><font color=#ff8000>return</font> </font>prev; }  <font color = #ff0080>/** Returns the next node of this node */</font>  <font color=#8000a0><font color=#8000a0>public</font> </font>DNode <font color=#0000ff>getNext</font>() { <font color=#8000a0><font color=#ff8000>return</font> </font>next; }  <font color = #ff0080>/** Sets the element of this node */</font>  <font color=#8000a0><font color=#8000a0>public</font> </font><font color=#8000a0>void</font> <font color=#0000ff>setElement</font>(<font color=#8000a0>String</font> newElem) { element = newElem; }  <font color = #ff0080>/** Sets the previous node of this node */</font>  <font color=#8000a0><font color=#8000a0>public</font> </font><font color=#8000a0>void</font> <font color=#0000ff>setPrev</font>(DNode newPrev) { prev = newPrev; }  <font color = #ff0080>/** Sets the next node of this node */</font>  <font color=#8000a0><font color=#8000a0>public</font> </font><font color=#8000a0>void</font> <font color=#0000ff>setNext</font>(DNode newNext) { next = newNext; }}</dl></body></html>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?