当前位置: 首页 > news >正文

自己做网站的劣势怎么在手机上制作软件

自己做网站的劣势,怎么在手机上制作软件,重庆龙华网站建设公司,网站客户案例模拟实现LinkedList:下一篇文章 LinkedList底层是双向、不带头结点、非循环的链表 /*** LinkedList的模拟实现*单向 不带头 非循环链表实现*/ class SingleLinkedList {class ListNode {public int val;public ListNode next;public ListNode(int val) {this.val …

 模拟实现LinkedList:下一篇文章

LinkedList底层是双向、不带头结点、非循环的链表

/*** LinkedList的模拟实现*单向 不带头 非循环链表实现*/
class SingleLinkedList {class ListNode {public int val;public ListNode next;public ListNode(int val) {this.val = val;}}public ListNode head;//永远指向头结点//创建链表public void createList() {ListNode node1 = new ListNode(1);ListNode node2 = new ListNode(2);ListNode node3 = new ListNode(3);ListNode node4 = new ListNode(4);ListNode node5 = new ListNode(5);node1.next = node2;node2.next = node3;node3.next = node4;node4.next = node5;this.head = node1;}//显示public void display() {while (head != null) {System.out.print(head.val + " ");head = head.next;//head往后移}}//得到单链表的长度public int size() {ListNode cur = head;int count = 0;while (cur != null) {count++;cur = cur.next;}return count;}//清空public void clear() {this.head = null;}//头插法public void addFirst(int data) {ListNode node = new ListNode(data);node.next = head;head = node;}//尾插法public void addLast(int data) {ListNode cur = head;ListNode node = new ListNode(data);if (head == null) {head = node;}while (cur.next != null) {cur = cur.next;}cur.next = node;//这时cur就是尾巴节点}//在任意位置插入,第一个数据节点为0的下标public void addIndex(int index, int data) {ListNode node = new ListNode(data);int len = size();//0.判断index位置是否合法if (index < 0 || index > len) {return;//也可以抛异常}//1.先找到index-1的位置  下面有个findIndex方法ListNode cur = findIndex(index);//2.插入数据node.next = cur.next;cur.next = node;}private ListNode findIndex(int index) {ListNode cur = head;while (index - 1 != 0) {cur = cur.next;index--;}return cur;//index-1位置的节点}//查找是否包含关键字key是否在单链表当中public boolean contains(int key) {ListNode cur = head;while (cur != null) {if (cur.val == key) {return true;}cur = cur.next;}return false;}//删除第一次出现关键字为key的节点public void remove(int key) {if(head==null){return;}if(head.val==key){head=head.next;return;}ListNode prev = searchPrev(key);if (prev== null) {System.out.println("没有这个数据");return;}ListNode del=prev.next;prev.next=del.next;}private ListNode searchPrev(int key){ListNode prev=head;while(prev.next!=null){if(prev.next.val==key){return prev;}else{prev=prev.next;}}return null;}//删除所有值为key的节点public void removeAllkey(int key) {if(head==null){return;}ListNode cur=head.next;ListNode prev=head;while(cur!=null){if(cur.val==key){prev.next=cur.next;cur=cur.next;}else{prev=cur;cur=cur.next;}}if(head.val==key){head=head.next;}}
}
public class Test {public static void main(String[] args) {SingleLinkedList singleLinkedList=new SingleLinkedList();singleLinkedList.createList();singleLinkedList.display();}
}

此处只调用了createList()和display()。需要其他方法的自己可以在main中调用哦

http://www.yayakq.cn/news/34762/

相关文章:

  • 荼叶公司网站模板昆山网站建设kshuituo
  • 网站开发php未来发展网络营销就是建立企业网站
  • asp网站怎么做地方门户网站有前景吗
  • 青年汇网站开发公司帮做论文网站吗
  • 网站开发需要的资源wordpress子站
  • 帝国系统做网站地图wordpress和自己写
  • 深圳深度网站建设辽宁建设工程信息网中标通知书
  • 上海哪个网站最好用网络规划设计师 最高分
  • 天津品牌网站建设公司排名东莞公司网站制作要多少钱
  • 网站建设方案调查分析报告自己做的网站如何放到微信
  • 英文网站建设注意事项热门网站建设加盟平台
  • 网站群管理中企动力是国企性质吗
  • 深圳品牌网站建设公司哪家好珠海最新消息今天
  • 怎么样做网站卖农产品怎样在网上注册免费的网站
  • 如何查找网站根目录wordpress签到积分
  • 通过高新区网站建设wordpress邮件发送下载
  • 湛江免费建站哪里有做家装的设计公司网站
  • 网站怎么做引流呢石家庄信息门户网站定制
  • 建站工具介绍常州互联网公司
  • 成都网站关键字优化网站运行环境建设方案
  • 福建路桥建设有限公司网站网站建设学费
  • 网站添加备案号网站开发需要提供哪些资料
  • app安装下载官网企业网站优化服务
  • 网站建设方面的书籍推荐程序员需要考哪些证书
  • 医院网站建设的计划vi设计和品牌设计的区别
  • 做卡盟网站襄阳网站seo诊断
  • 有云服务器怎么做网站怎么下载网站程序
  • 网站pv uv统计制作网站需要wordpress
  • 垂直电商网站有哪些做网站asp
  • 二手商品网站的设计与建设论文建行个人帐户余额查询