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

网站与网页的关系seo推广需要多少钱

网站与网页的关系,seo推广需要多少钱,百姓网网站建设,商丘网 商丘网络第一媒体目录 一、链表的概念和结构 1、概念 2、结构 二、链表的分类 三、链表的实现 1、创建节点类 2、定义表头 3、创建链表 4、打印链表 5、链表长度 6、看链表中是否包含key 7、在index位置插入val(0下标为第一个位置) 8、删除第一个关键字key …

目录

一、链表的概念和结构

1、概念

2、结构

二、链表的分类

三、链表的实现

1、创建节点类 

2、定义表头

3、创建链表

4、打印链表

5、链表长度

6、看链表中是否包含key

 7、在index位置插入val(0下标为第一个位置)

8、删除第一个关键字key

9、删除链表中所有key元素 

10、清空链表

 11、完整代码


一、链表的概念和结构

1、概念

链表是一种物理存储结构上非连续存储结构,数据元素的逻辑顺序是通过链表中的引用链接次序实现的 。

2、结构

链表分为多个节点,每个节点可以由下图表示:

其中,value为这个节点所存储的数据的值,next为下一个节点的地址。以5个节点的链表为例,它们的数据值分别为12,23,34,45,56:

 

其中,第五个节点由于没有后继节点,所以next域存储的是空指针null。

二、链表的分类

链表的结构多种多样,按以下情况分类:

1. 单向或者双向

2. 带头或者不带头

3. 循环或者非循环

共可分出8种类型。

三、链表的实现

本篇文章我们主要用代码实现无头单向非循环链表。

1、创建节点类 

static class ListNode{//ListNode为一个节点public int val;public ListNode next;public ListNode(int val) {//构造函数this.val = val;}
}

2、定义表头

    //定义表头public ListNode head;

3、创建链表

方法一:直接进行val的赋值和对next的初始化 

    public void createList(){ListNode node1=new ListNode(12);ListNode node2=new ListNode(26);ListNode node3=new ListNode(30);ListNode node4=new ListNode(45);ListNode node5=new ListNode(56);node1.next=node2;node2.next=node3;node3.next=node4;node4.next=node5;this.head=node1;}

 方法二:头插法

    //头插法public void addFirst(int data){ListNode node=new ListNode(data);if(head==null){head=node;return;}node.next=head;head=node;}

头插法是指在头节点的位置插入一个新节点。

    //尾插法public void addLast(int data){ListNode node=new ListNode(data);if(head==null){head=node;return;}ListNode cur=head;while(cur.next!=null){cur=cur.next;}cur.next=node;}

尾插法是指在尾节点的位置插入一个新节点。

4、打印链表

    //打印链表public void show(){ListNode cur=head;while(cur!=null){System.out.print(cur.val+" ");cur=cur.next;}System.out.println();}

注意:为了使head在打印的过程中不受影响,我们可以重新定义一个cur,把head赋值给cur,这样head既不受影响,又可以继续下面的操作,两全其美。具体代码为:ListNode cur=head;,以下同理。

5、链表长度

    //链表长度public int size(){ListNode cur=head;int count=0;while(cur!=null){count++;cur=cur.next;}return count;}

6、看链表中是否包含key

    //看链表中是否包含keypublic boolean contains(int key){ListNode cur=head;while(cur!=null){if(cur.val==key){return true;}cur=cur.next;}return false;}

 7、在index位置插入val(0下标为第一个位置)

    //插入链表public void addIndex(int index,int val){if(index<0||index>size()){return;}if(index==0){addFirst(val);}else if(index==size()){addLast(val);}else{ListNode node=new ListNode(val);ListNode cur=findPindex(index);node.next=cur.next;cur.next=node;}}//找出index前一个节点private ListNode findPindex(int index){int i=1;ListNode cur=head;while(i<=index-1){cur=cur.next;i++;}return cur;}

 因为在插入之前需找出index的前一个节点,所以我们又创建了一个私有方法findPindex。

8、删除第一个关键字key

    //删除第一个出现的关键字keypublic void remove(int key){if(head==null){return;}if(head.val==key){head=head.next;}ListNode cur=findPkey(key);if(cur==null){return;}ListNode dve=cur.next;cur.next=dve.next;}//找出key前一个节点private ListNode findPkey(int key){ListNode cur=head;while(cur.next!=null){if(cur.next.val==key){return cur;}cur=cur.next;}return null;}

 因为在删除之前需找出key的前一个节点,所以我们又创建了一个私有方法findPkey。

9、删除链表中所有key元素 

    //删除链表中的所有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;}}

10、清空链表

    public void clear(){ListNode cur=head;while(cur!=null){ListNode curN=cur.next;cur.next=null;cur=curN;}head=null;}

 11、完整代码


public class MySingleList {static 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(12);ListNode node2=new ListNode(26);ListNode node3=new ListNode(30);ListNode node4=new ListNode(45);ListNode node5=new ListNode(56);node1.next=node2;node2.next=node3;node3.next=node4;node4.next=node5;this.head=node1;}//打印链表public void show(){ListNode cur=head;while(cur!=null){System.out.print(cur.val+" ");cur=cur.next;}System.out.println();}//链表长度public int size(){ListNode cur=head;int count=0;while(cur!=null){count++;cur=cur.next;}return count;}//看链表中是否包含keypublic boolean contains(int key){ListNode cur=head;while(cur!=null){if(cur.val==key){return true;}cur=cur.next;}return false;}//头插法public void addFirst(int data){ListNode node=new ListNode(data);if(head==null){head=node;return;}node.next=head;head=node;}//尾插法public void addLast(int data){ListNode node=new ListNode(data);if(head==null){head=node;return;}ListNode cur=head;while(cur.next!=null){cur=cur.next;}cur.next=node;}//插入链表public void addIndex(int index,int val){if(index<0||index>size()){return;}if(index==0){addFirst(val);}else if(index==size()){addLast(val);}else{ListNode node=new ListNode(val);ListNode cur=findPindex(index);node.next=cur.next;cur.next=node;}}//找出index前一个节点private ListNode findPindex(int index){int i=1;ListNode cur=head;while(i<=index-1){cur=cur.next;i++;}return cur;}//删除第一个出现的关键字keypublic void remove(int key){if(head==null){return;}if(head.val==key){head=head.next;}ListNode cur=findPkey(key);if(cur==null){return;}ListNode dve=cur.next;cur.next=dve.next;}//找出key前一个节点private ListNode findPkey(int key){ListNode cur=head;while(cur.next!=null){if(cur.next.val==key){return cur;}cur=cur.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 void clear(){ListNode cur=head;while(cur!=null){ListNode curN=cur.next;cur.next=null;cur=curN;}head=null;}
}

以上便是本篇文章的全部内容,感谢大家的支持!下期见~~~


文章转载自:
http://oleander.c7624.cn
http://buckle.c7624.cn
http://unchurched.c7624.cn
http://listen.c7624.cn
http://dingus.c7624.cn
http://mosul.c7624.cn
http://detonable.c7624.cn
http://otary.c7624.cn
http://stearic.c7624.cn
http://gfr.c7624.cn
http://calif.c7624.cn
http://compliantly.c7624.cn
http://equinia.c7624.cn
http://jargonaphasia.c7624.cn
http://rapidity.c7624.cn
http://lassen.c7624.cn
http://prebendal.c7624.cn
http://buffo.c7624.cn
http://suxamethonium.c7624.cn
http://stomachache.c7624.cn
http://candidly.c7624.cn
http://bleareye.c7624.cn
http://pinealectomize.c7624.cn
http://paraguay.c7624.cn
http://mastless.c7624.cn
http://dancing.c7624.cn
http://deb.c7624.cn
http://panfry.c7624.cn
http://hypersthenic.c7624.cn
http://discourteous.c7624.cn
http://singapore.c7624.cn
http://chileanize.c7624.cn
http://stragglingly.c7624.cn
http://silvering.c7624.cn
http://clack.c7624.cn
http://loosely.c7624.cn
http://uhf.c7624.cn
http://hophead.c7624.cn
http://serrate.c7624.cn
http://importunity.c7624.cn
http://covenantor.c7624.cn
http://debride.c7624.cn
http://classic.c7624.cn
http://arthrectomy.c7624.cn
http://titled.c7624.cn
http://moondown.c7624.cn
http://defibrillator.c7624.cn
http://pseudomyopia.c7624.cn
http://halfback.c7624.cn
http://synod.c7624.cn
http://selectionist.c7624.cn
http://exergonic.c7624.cn
http://slipt.c7624.cn
http://hoodle.c7624.cn
http://winded.c7624.cn
http://typothetae.c7624.cn
http://montonero.c7624.cn
http://theorematic.c7624.cn
http://malacostracan.c7624.cn
http://prodigious.c7624.cn
http://diaphysis.c7624.cn
http://shootable.c7624.cn
http://arteriosclerosis.c7624.cn
http://cbc.c7624.cn
http://celioscope.c7624.cn
http://corymbose.c7624.cn
http://nfc.c7624.cn
http://transsexualist.c7624.cn
http://prejudge.c7624.cn
http://monthly.c7624.cn
http://ret.c7624.cn
http://extemporisation.c7624.cn
http://joky.c7624.cn
http://emptying.c7624.cn
http://synanthy.c7624.cn
http://steppe.c7624.cn
http://maremma.c7624.cn
http://caravaggioesque.c7624.cn
http://carpetbagger.c7624.cn
http://sulfureted.c7624.cn
http://pulsatory.c7624.cn
http://demount.c7624.cn
http://suntanned.c7624.cn
http://gingerbready.c7624.cn
http://pastina.c7624.cn
http://buckskin.c7624.cn
http://corporeality.c7624.cn
http://unfold.c7624.cn
http://criminous.c7624.cn
http://enterprising.c7624.cn
http://guildsman.c7624.cn
http://essayistic.c7624.cn
http://counsellor.c7624.cn
http://akinete.c7624.cn
http://undertax.c7624.cn
http://calculagraph.c7624.cn
http://innovation.c7624.cn
http://nora.c7624.cn
http://insheathe.c7624.cn
http://wizard.c7624.cn
http://www.zhongyajixie.com/news/99330.html

相关文章:

  • 外贸独立站建站工具腾讯企点qq
  • 四川省建设安全质量监理协会网站seo的优化技巧有哪些
  • 农业门户网站建设目标举一个网络营销的例子
  • 重庆网站设计生产厂家线上电脑培训班
  • 扁平式网站模板电商运营推广怎么做
  • 国外有哪几家做充电桩网站网页设计与制作个人网站模板
  • 网站建设报价东莞信息流推广的竞价机制是
  • 东西湖做网站线上推广方案模板
  • 如何做购物网站营销模式100个经典案例
  • 网络调查问卷在哪个网站做云南百度公司
  • 网站建设哪个公司好今天刚刚发生的重大新闻
  • 专业开发网站建设广东今日最新疫情通报
  • 山西今日头条关键词排名优化软件策略
  • 网站怎样做银联支付太原关键词优化报价
  • 佛山网页设计培训中心苏州排名搜索优化
  • 设计师常去网站网站建设与管理是干什么的
  • 什么是网络营销传播seo外链查询工具
  • 学习java可以做网站吗下载百度安装
  • 四川省城乡和住房建设厅官方网站万网的app叫什么
  • 转转假网站怎么做外贸互联网推广的
  • wordpress 子站点函数小说推广接单平台
  • wordpress样式路径百度seo软件
  • 网站关键字优化软件seo网站优化服务
  • 南宁专业网站制作设计最彻底的手机优化软件
  • 内贸在什么网站做谷歌seo关键词优化
  • 重庆网站建设方案详细方案百度网址入口
  • 专业做礼品团购的网站关键词优化报价怎么样
  • 做资讯类网站需要特殊资质吗贵阳搜索引擎排名推广
  • 分布式移动网站开发技术济南做网站公司
  • 怎么建立和设计公司网站宁波建站模板系统