?? linkedlist.java
字號:
package work_1;
//鏈表實現
public class LinkedList {
private LinkNode headNode = null;
private LinkNode tailNode = null;
private LinkNode currentNode = null;
private int length = 0;
public int getLength() {
return length;
}
public void setLength(int length) {
this.length = length;
}
public LinkNode getHeadNode() {
return headNode;
}
public void setHeadNode(LinkNode headNode) {
this.headNode = headNode;
}
public LinkNode getTailNode() {
return tailNode;
}
public void setTailNode(LinkNode tailNode) {
this.tailNode = tailNode;
}
public LinkNode getCurrentNode() {
return currentNode;
}
public void setCurrentNode(LinkNode currentNode) {
this.currentNode = currentNode;
}
//增加節點
public void addNode(LinkNode nodeInsert) {
if (this.getLength() == 0) {
headNode = nodeInsert;
currentNode = headNode;
this.length++;
} else {
currentNode.setNextLinkNode(nodeInsert);
currentNode = nodeInsert;
this.length++;
}
}
// 判斷是否到終點
public boolean hasNextNode() {
currentNode = currentNode.getNextNode();
if (currentNode == null) {
return false;
} else {
return true;
}
}
//把鏈表頭設為當前節點
public LinkNode resetHead() {
currentNode = headNode;
return currentNode;
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -