java data structure - Common linked list implementation

com.node Package; 

/ **
* @auther strong Fu
* @date 2020/2/14 - 9:20
* /
// node
// list ordinary
public class the Node {
// node content
int Data;
// next node
the node Next;
public the node (int Data) {
this.data = Data;
}
// append node to node
public the append the node (the node node) {
// current node
the node = the currentNode the this;
// Get back loop
while (true ) {
// fetches the next node
the node nextNode = currentNode.next;
// if the next node is null, the current node is the last node in the
IF (nextNode == null) {
BREAK;
}
// current node assigned to
the currentNode = nextNode;
}
// Some recoveries were to find the next current node
currentNode.next = Node;
return the this;
}
// Insert a node is added to the current node to find a node
public void After (the node node) {
// fetches the next node as the next node at
nextNext = next the node;
// the new node as the next current node
this.next = node;
// the second next the next node is set to a new node
node.next = nextNext;

}
// show all node information
public void Show () {
the node = the currentNode the this;
the while (to true) {
of System.out.print (currentNode.data + "") ;
// fetches the next node
= currentNode.next the currentNode;
// if it is the last node
IF (the currentNode == null) {
BREAK;
}
}
System.out.println ();
}
next // delete a node
public void removeNext () {
// first remove the next node
the node next = this.next.next;
// the next node as the next current node is a node
this.next = next;
}

// get the next node
public the node next () {
return the this. Next;
}
// get the data node
public int the getData () {
return this.data;
}
// current node is the last node
public boolean isLast () {
return next==null;
}
}

Guess you like

Origin www.cnblogs.com/fuqiang-java/p/12309165.html