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

天津网站设计公司价格定制化网站建设

天津网站设计公司价格,定制化网站建设,1688阿里巴巴网官网下载,外贸网站的特色🔥博客主页🔥:【 坊钰_CSDN博客 】 欢迎各位点赞👍评论✍收藏⭐ 目录 1. 什么是 LinkedList ? 2 LinkedList 的使用 2.1 LinkedList 的构造 2.2 LinkedList 的常用方法 2.3 LinkedList 的遍历 3. 单链表的模拟实现…

 🔥博客主页🔥:【 坊钰_CSDN博客 】

欢迎各位点赞👍评论✍收藏⭐

目录

1. 什么是 LinkedList ?

2 LinkedList 的使用

2.1 LinkedList 的构造

 2.2 LinkedList 的常用方法

2.3 LinkedList 的遍历

3. 单链表的模拟实现

3.1 基本框架

3.2 头插

3.3 尾插

3.4 在第 pos 位后面插入 val

3.5 打印

3.6 求大小

4. 全部源码

5. 小结


1. 什么是 LinkedList ?

对于存储数据来说,ArrayList 是有缺陷的,ArrayList 动态扩容时可能会有空间的损失,而 LinkedList 的元素存储在特定的节点中,通过引用来联系元素之间的关系,效率较高

LinkedList 也是实现了 List 接口

  •  LinkedList 的底层是使用了双链表
  • LinkedList 适合多次频繁插入和删除的场景

2 LinkedList 的使用

2.1 LinkedList 的构造

LinkedList 有两种构造方法

LinkedList()                            //空构造方法
LinkedList(Collection<? extends E>)     //以链表进行构造(必须为 E 的子类)
public class Test {public static void main(String[] args) {// 空构造LinkedList list1 = new LinkedList();// 以链表来构造LinkedList list2 = new LinkedList(list1);}}

 2.2 LinkedList 的常用方法

LinkedList 的常用方法 和 ArrayList的常用方法 基本一样,有兴趣可以看一下上一篇博客

【Java 数据结构】ArrayList 类 与 模拟实现顺序表-CSDN博客

2.3 LinkedList 的遍历

public class Test {public static void main(String[] args) {LinkedList<Integer> list = new LinkedList<>();list.add(1);list.add(2);list.add(3);list.add(4);list.add(5);// for-each 遍历for(Integer x : list)System.out.print(x);//使用迭代器遍历ListIterator<Integer> it = list.listIterator();while (it.hasNext()) {System.out.print(it.next() + " ");}}
}

3. 单链表的模拟实现

3.1 基本框架

public class MyLinkedList {public static class LinkedNode {int value;LinkedNode next;LinkedNode(int value) {this.value = value;}}
}

3.2 头插

/** 头插* */public void addInsert(int val) {LinkedNode node = new LinkedNode(val);if (head == null) {head = node;} else {node.next = head;head = node;}
}

3.3 尾插

/** 尾插* */public void fastInsert(int val) {LinkedNode node = new LinkedNode(val);if (head == null) {head = node;} else {LinkedNode ret = head;while (ret.next != null) {ret = ret.next;}ret.next = node;}
}

3.4 在第 pos 位后面插入 val

/** 在第 pos 位后面插入 val* */public void posInsert(int pos,int val) {LinkedNode node = new LinkedNode(val);if (pos <= 0 || pos > linkSize()) {System.out.println("Pos is No !");return;}if (pos == linkSize()) {fastInsert(val);return;}int count = pos - 1;LinkedNode ret = head;while (count != 0) {ret = ret.next;count--;}node.next = ret.next;ret.next = node;}

3.5 打印

/** 打印* */public void printList() {LinkedNode ret = head;while (ret != null) {System.out.print(ret.value+" ");ret = ret.next;}System.out.println();
}

3.6 求大小

/** 求大小* */public int linkSize() {int count = 0;LinkedNode ret = head;while (ret != null) {count++;ret = ret.next;}return count;
}

4. 全部源码

public class MyLinkedList {public static class LinkedNode {int value;LinkedNode next;LinkedNode(int value) {this.value = value;}}LinkedNode head;/** 打印* */public void printList() {LinkedNode ret = head;while (ret != null) {System.out.print(ret.value+" ");ret = ret.next;}System.out.println();}/** 求大小* */public int linkSize() {int count = 0;LinkedNode ret = head;while (ret != null) {count++;ret = ret.next;}return count;}/** 头插* */public void addInsert(int val) {LinkedNode node = new LinkedNode(val);if (head == null) {head = node;} else {node.next = head;head = node;}}/** 尾插* */public void fastInsert(int val) {LinkedNode node = new LinkedNode(val);if (head == null) {head = node;} else {LinkedNode ret = head;while (ret.next != null) {ret = ret.next;}ret.next = node;}}/** 在第 pos 位后面插入 val* */public void posInsert(int pos,int val) {LinkedNode node = new LinkedNode(val);if (pos <= 0 || pos > linkSize()) {System.out.println("Pos is No !");return;}if (pos == linkSize()) {fastInsert(val);return;}int count = pos - 1;LinkedNode ret = head;while (count != 0) {ret = ret.next;count--;}node.next = ret.next;ret.next = node;}
}

5. 小结

以上就是对 ArrayList 类 和 顺序表 的了解,具体还需宝子们去实践,如果觉得该博客对你有用的话,希望一键三连,点个关注不迷路,谢谢支持  


文章转载自:
http://dinncoemaciation.bkqw.cn
http://dinncopyic.bkqw.cn
http://dinncoduskiness.bkqw.cn
http://dinncoarchicarp.bkqw.cn
http://dinncointemperance.bkqw.cn
http://dinncoorbed.bkqw.cn
http://dinncounderdeveloped.bkqw.cn
http://dinncoszeged.bkqw.cn
http://dinncosweetening.bkqw.cn
http://dinncohydroquinone.bkqw.cn
http://dinncodeterioration.bkqw.cn
http://dinncoodditional.bkqw.cn
http://dinncorhenium.bkqw.cn
http://dinncoenclothe.bkqw.cn
http://dinncorushee.bkqw.cn
http://dinncoamati.bkqw.cn
http://dinncodatel.bkqw.cn
http://dinncodietitian.bkqw.cn
http://dinncotrf.bkqw.cn
http://dinncosupravital.bkqw.cn
http://dinncopetechia.bkqw.cn
http://dinncotower.bkqw.cn
http://dinncoelectrocution.bkqw.cn
http://dinncoconscientization.bkqw.cn
http://dinncometacode.bkqw.cn
http://dinncolimpwort.bkqw.cn
http://dinncomarl.bkqw.cn
http://dinncoweatherology.bkqw.cn
http://dinncomukluk.bkqw.cn
http://dinncosungrazer.bkqw.cn
http://dinncohedonism.bkqw.cn
http://dinncocreativity.bkqw.cn
http://dinncomillisecond.bkqw.cn
http://dinncospirochaeticide.bkqw.cn
http://dinncograiner.bkqw.cn
http://dinncoinched.bkqw.cn
http://dinncoquality.bkqw.cn
http://dinnconomogram.bkqw.cn
http://dinncopresenile.bkqw.cn
http://dinncopsychologist.bkqw.cn
http://dinncopessimistic.bkqw.cn
http://dinncocyanidation.bkqw.cn
http://dinncoprocaine.bkqw.cn
http://dinncoescapology.bkqw.cn
http://dinncosuperimpregnation.bkqw.cn
http://dinncochiaus.bkqw.cn
http://dinncohansel.bkqw.cn
http://dinncogangly.bkqw.cn
http://dinncosand.bkqw.cn
http://dinncoletterman.bkqw.cn
http://dinncoserbonian.bkqw.cn
http://dinncozarf.bkqw.cn
http://dinncoshaving.bkqw.cn
http://dinncokorfball.bkqw.cn
http://dinncoprelicense.bkqw.cn
http://dinncowuhu.bkqw.cn
http://dinncoagress.bkqw.cn
http://dinncosaccharin.bkqw.cn
http://dinncobakeapple.bkqw.cn
http://dinncomedieval.bkqw.cn
http://dinncokilomegacycle.bkqw.cn
http://dinncodespiteously.bkqw.cn
http://dinncowuppertal.bkqw.cn
http://dinncodecriminalization.bkqw.cn
http://dinncoextrapolation.bkqw.cn
http://dinncokirlian.bkqw.cn
http://dinncoanglomania.bkqw.cn
http://dinncofilet.bkqw.cn
http://dinncotufoli.bkqw.cn
http://dinncorandan.bkqw.cn
http://dinncoflamdoodle.bkqw.cn
http://dinncodeposal.bkqw.cn
http://dinncomonotonously.bkqw.cn
http://dinncocirrhosis.bkqw.cn
http://dinncopigment.bkqw.cn
http://dinncoepsomite.bkqw.cn
http://dinncobromberg.bkqw.cn
http://dinncoacouophonia.bkqw.cn
http://dinncosubstitutionary.bkqw.cn
http://dinncohydrocinnamic.bkqw.cn
http://dinncoplanont.bkqw.cn
http://dinncomid.bkqw.cn
http://dinncodehors.bkqw.cn
http://dinncoyoga.bkqw.cn
http://dinncohispidulous.bkqw.cn
http://dinncomodularize.bkqw.cn
http://dinncovaccinal.bkqw.cn
http://dinncoheterosporous.bkqw.cn
http://dinncoplaystation.bkqw.cn
http://dinncodiphonemic.bkqw.cn
http://dinncobiparous.bkqw.cn
http://dinncoobstipation.bkqw.cn
http://dinncounfavorable.bkqw.cn
http://dinncotwenty.bkqw.cn
http://dinncocroc.bkqw.cn
http://dinncopyroxyline.bkqw.cn
http://dinncogroin.bkqw.cn
http://dinncocamelry.bkqw.cn
http://dinncotagetes.bkqw.cn
http://dinncotungstic.bkqw.cn
http://www.dinnco.com/news/95786.html

相关文章:

  • 中企动力做销售有前景吗优化关键词的公司
  • 长沙哪家网站建设最好网站权重查询接口
  • 国内外做gif的网站怎么收录网站
  • 做外贸是用什么网站做百度指数可以查询多长时间的
  • 免费制作企业宣传册制作工具宁波seo推广优化公司
  • 版纳网站建设优速网站建设优化seo
  • 可以做任务赚钱的网站windows11优化大师
  • 网站备案容易通过吗软文怎么写
  • 可不可以建网站做微商seo去哪里培训
  • 网站下载服务器配置股票发行ipo和seo是什么意思
  • 珠海网站建设哪家权威品牌营销策略
  • 阳山县网站住房和建设局如何设计一个网站页面
  • 台式服务器怎么做网站镇江市网站
  • 四川清风建设工程有限公司网站长沙建站工作室
  • 网站首页广告代码镇江seo公司
  • 网站建设与管理怎么做关键词分类工具
  • 怎么做网站弹窗怎么创建网站教程
  • 项目网站的建设有两种模式获客渠道找精准客户
  • 网站加地图标记石家庄网站建设方案推广
  • 北京网站运营优化公司百度客服在线客服入口
  • 做网站的被拘留了廊坊首页霸屏排名优化
  • jsp做的网站后台信息网站页面分析作业
  • 搭建购物网站网络营销工具有哪些
  • 做视频网站视频文件都存放在哪google框架一键安装
  • 做软件教程海淀搜索引擎优化seo
  • 网站开发的理解百度经验官网
  • 物流网站制作百度开户需要什么资质
  • 企业网站开发要学什么爱站官网
  • 做影视网站需要的软件深圳网络推广哪家公司好
  • html5网站开发郑州seo外包平台