📄 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 + -