java data structure - realized circular list

com.node Package; 

/ **
* @auther strong Fu
* @date 2020/2/14 - 9:20
* /
// node
// circular linked list
public class LoopNode {
// node content
int Data;
// next node (circular list just add to this a)
LoopNode next = this;
public LoopNode (int Data) {
this.data = Data;
}
// insert a node is added to the next node of the current node to find
public void after ( LoopNode node) {
next // remove a node as the next node the next
LoopNode nextNext = next;
// the new node as the next current node
this.next = node;
// to set the next node to the new node next node
node.next = nextNext;

}
// delete the next node
public void removeNext () {
// first remove the next node
LoopNode Next = this.next.next;
// at the next node as the next current node
this.next = Next;
}

// get the next node
public LoopNode next () {
return this.next;
}
// get the data node
public int the getData () {
return this.data;
}
}

Guess you like

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