数据结构--单链表实现 no 5.

单链表概念图形:

在这里插入图片描述

双链表以及双向循环链表:

在这里插入图片描述

单链表实现:

定义存放结点数据和信息的类:

package com.st.datastructure.lineable;
/**
 * 单链表的结点
 * 
 *
 * @author God's Night Is Not Ended
 */
public class Node {
	
	 Object data;//需要存储的数据
	 Node next;//存放下一个结点
	 public Node() {
			
		}
	
	public Node(Object data) {
		super();
		this.data = data;
	}
	public Node(Object data, Node next) {
		super();
		this.data = data;
		this.next = next;
	}
	public Object getData() {
		return data;
	}
	public void setData(Object data) {
		this.data = data;
	}
	public Node getNext() {
		return next;
	}
	public void setNext(Node next) {
		this.next = next;
	}
	

}


添加操作:

在这里插入图片描述

删除操作:

在这里插入图片描述

发布了76 篇原创文章 · 获赞 9 · 访问量 6784

猜你喜欢

转载自blog.csdn.net/qq_37870369/article/details/89488138