准备一些链表和节点的实体,方便后面使用
java代码
/** * @Description:构造一个链表实体,方便后续构造链表 * @Author: lizhouwei * @CreateDate: 2018/4/6 8:46 * @Modify by: * @ModifyDate:*/public class Link { public Node head; public DoubleNode dhead; public void add(int vlaue) { Node node = new Node(vlaue); if (head == null) { head = node; } else { node.next = head; head = node; } } public void addDoubleNode(int vlaue) { DoubleNode node = new DoubleNode(vlaue); if (dhead == null) { dhead = node; } else { node.next = dhead; dhead.pre =node; dhead = node; } }}class Node { public int vlaue; public Node next; public Node(int vlaue) { this.vlaue = vlaue; }}class DoubleNode{ public int vlaue; public DoubleNode pre; public DoubleNode next; public DoubleNode(int vlaue) { this.vlaue = vlaue; }}