单链表,以及反转递归实现,

/**
 * @author By zhouwx5
 * @Created on by 2019/11/19
 * @Desc:
 */
public class  LinkedNode {

    private Node header;
    private Node tail;
    private int size;

    private void linkList(){
        header =null;
        tail =null;
    }

    private void linkList(T element){
        header =new Node(element,null);
        tail =header;
        size++;
    }
    private int length(){
        return size;
    }

    /**
     * 获取给定索引的值
     * @param index 给定索引
     * @return 返回值
     */
    private T get(int index){
        return (T) this.getNodeIndex(index).getDate();
    }

    /**
     * 获取当前节点
     * @param index 索引
     * @return index所代表的节点
     */
    private Node getNodeIndex(int index) {
        if (index<0||index>size-1) {
            System.out.println("无节点");
            throw new IndexOutOfBoundsException("索引超出范围");
        }
        Node currend =header;
        for (int i =0;i

 

你可能感兴趣的:(单链表,以及反转递归实现,)