nodequeue-enqueue.html

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

HTML
24
字号
<html><head><title>Code Fragment</title></head><body text=#000000><center></center><br><br><dl><dd><pre>  <font color=#8000a0><font color=#8000a0>public</font> </font><font color=#8000a0>void</font> <font color=#0000ff>enqueue</font>(E elem) {    Node&lt;E&gt; node = <font color=#8000a0><font color=#ff8000>new</font> </font>Node&lt;E&gt;<font color=#0000ff></font>();    node.<font color=#0000ff>setElement</font>(elem);    node.<font color=#0000ff>setNext</font>(null); <font color=#ff0080>// node will be new tail node</font>    <font color=#ff8000>if</font><font color=#0000ff> </font>(size == 0)      head = node; <font color=#ff0080>// special case of a previously empty queue</font>    <font color=#ff8000>else</font>      tail.<font color=#0000ff>setNext</font>(node); <font color=#ff0080>// add node at the tail of the list</font>    tail = node; <font color=#ff0080>// update the reference to the tail node</font>    size++;  }</dl></body></html>

⌨️ 快捷键说明

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