线性结构(二)--- 双链表

 1 public class DoubleNode {
 2     //上一个节点
 3     DoubleNode pre=this;
 4     //下一个节点
 5     DoubleNode next=this;
 6     //节点数据
 7     int data;
 8     
 9     public DoubleNode(int data){
10         this.data=data;
11     }
12     
13     //增节点
14     public void after(DoubleNode node){
15         //原来的下一个节点
16         DoubleNode nextNext=next;
17         //把新节点作为当前节点的下一个节点
18         this.next=node;
19         //把当前节点的下一个节点设为新节点
20         node.pre=this;
21         //让原来的下一个节点设为新节点的下一个节点
22         node.next=nextNext;
23         //让原来的下一个节点的上一个节点为新节点
24         nextNext.pre=node;
25     }
26     
27     //下一个节点
28     public DoubleNode next(){
29         return this.next;
30     }
31     //上一个节点
32     public DoubleNode pre(){
33         return this.pre;
34     }
35     //获取数据
36     public int getData(){
37         return this.data;
38     }
39     
40 }
好好学习,天天向上。 努力工作,给自己的和家人一个满意的答案。。。。
原文地址:https://www.cnblogs.com/axu521/p/9968920.html