Advertisement

Java数据结构与算法:双链表LinkedList

阅读量:

双链表 LinkedList 结构解析

实现代码

复制代码
    package com.lhs;
    
    public class LinkedList<E> implements List<E>{
    // 定义链表长度
    private int size;
    
    // 定义头节点
    private Node<E> first;
    
    // 定义尾节点
    private Node<E> last;
    
    // 内部类,定义节点
    public static class Node<E>{
        // 定义节点数据
        E data;
        // 定义下一个节点
        Node<E> next;
    
        // 定义前一个节点
        Node<E> pre;
    
        // 构造函数,用于创建新的节点
        Node(E data,Node<E> next,Node<E> pre){
            this.data = data;
            this.next = next;
            this.pre = pre;
        }
    }

全部评论 (0)

还没有任何评论哟~