Java数据结构与算法分析《四》链表
来源:互联网 发布:网络性质的公司 编辑:程序博客网 时间:2024/05/21 18:39
链接点
//链接点 相当于车厢public class Node{ //数据域 public long data; //指针域 public Node next; public Node(long value){ this.data = data; } //显示方法 public void display(){ System.out.println(data+" "); }}
链表
//链表相当于火车public class LinkList{ //头结点 private Node first; public LinkList(){ first = null; } //插入一个节点 在头结点后进行插入 public void insertFirst(long value){ Node node = new Node(); Node.next = first; first = node; } //删除一个节点 在头结点后进行删除 public void deleteFirst(){ Node temp = first; first = temp.next; return temp; } //显示方法 public void display(){ Node current =frist; while(current!=null){ current.display(); current =current.next(); } System.out.println(); } //查找方法 public Node find(long value){ Node current = first; while(current.data!=null){ if(cuurent.next == null){ return null; } current = current.next; } return cuurent; } //删除方法 根据数据域来进行删除 public Node delete(long value){ Node current =first; Node previous =first; while(current.data!=value){ if(current.next == null){ return null; } previous =current; cuurent = current.next; } if(current == first){ first = first.next; } else { previous.next = current.next; } return current; }}
0 0
- Java数据结构与算法分析《四》链表
- <四>java数据结构与算法 插入排序
- (数据结构与算法分析 四)------数组循环队列的实现( Java语言描述)
- 【数据结构与算法分析】链表
- 数据结构与算法四
- 数据结构与算法分析(JAVA版)
- 数据结构与算法分析 java语言描述
- java数据结构与算法分析之递归
- Java数据结构与算法分析《六》递归
- Java数据结构与算法分析《十四》红黑树
- 【数据结构与算法】四 链表 反转
- 数据结构与算法(四)链表
- 数据结构与算法之四(链表)
- 数据结构算法与分析
- 数据结构与算法分析
- 数据结构与算法分析
- 数据结构与算法分析
- 数据结构与算法分析
- leetcode- 215. Kth Largest Element in an Array(基于快速排序思想)
- Python小练习
- 文章标题
- hive优化--增加减少map数
- c# HTTP请求
- Java数据结构与算法分析《四》链表
- 嗯,我的第一篇博客。
- Android socket 自制框架 (client+console+bean)
- POJ1007过河问题 贪心||DP
- 【C++学习笔记】for循环中的复合语句(语句块)
- uva439 -- Knight Moves
- 进制数的转化
- Android 思维导图
- 模拟实现 list