• java数据结构-双向循环链表实现


    package com.node;

    /**
    * @auther 付强
    * @date 2020/2/14 - 13:32
    */
    public class DoubleNode {
    //上一个节点(等于this)保证循环
    DoubleNode pre=this;
    //下一个节点
    DoubleNode next=this;
    //节点数据
    int data;
    public DoubleNode(int data){
    this.data=data;
    }
    //增加节点
    public void after(DoubleNode node){
    //原来的下一个节点
    DoubleNode nextNext=next;
    //把新节点作为当前节点的下一个节点
    this.next=node;
    //把当前节点作为新节点的前一个节点
    node.pre=this;
    //让原来的下一个节点作为新节点的下一个节点
    node.next=nextNext;
    //让原来的下一个节点的上一个节点为新节点
    nextNext.pre=node;
    }
    //下一个节点
    public DoubleNode next(){
    return this.next;
    }
    //上一个节点
    public DoubleNode pre(){
    return this.pre;
    }
    //获取数据
    public int getData(){
    return this.data;
    }

    }
  • 相关阅读:
    Web Designer Intern
    Internship UI/UX Web Designer
    HTML / CSS Frontend Software Engineer Internship
    CSS 07 文本
    CSS 06 背景
    CSS 05 尺寸大小
    CSS 04 注释
    CSS 03 选择器
    Why Ancient Greeks are Always Nude
    C#表示空字符
  • 原文地址:https://www.cnblogs.com/fuqiang-java/p/12309186.html
Copyright © 2020-2023  润新知