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

现在个人网站怎么备案互联网推广

现在个人网站怎么备案,互联网推广,WordPress全球用户量2019,ui设计怎么自学ArrayList和LinkedList有什么区别? ArrayList 是基于数组实现的,LinkedList 是基于链表实现的。 二者用途有什么不同? 多数情况下,ArrayList更利于查找,LinkedList更利于增删 由于 ArrayList 是基于数组实现的&#…

ArrayList和LinkedList有什么区别?

  • ArrayList 是基于数组实现的,LinkedList 是基于链表实现的。
    在这里插入图片描述
    二者用途有什么不同?

  • 多数情况下,ArrayList更利于查找,LinkedList更利于增删

    1. 由于 ArrayList 是基于数组实现的,所以 get(int index) 可以直接通过数组下标获取,时间复杂度是 O(1);LinkedList 是基于链表实现的,get(int index) 需要遍历链表,时间复杂度是 O(n)。
      当然,get(E element) 这种查找,两种集合都需要遍历通过 equals 比较获取元素,所以时间复杂度都是 O(n)。

    2. ArrayList 如果增删的是数组的尾部,直接插入或者删除就可以了,时间复杂度是 O(1);如果 add 的时候涉及到扩容,时间复杂度会提升到 O(n)。

      但如果插入的是中间的位置,就需要把插入位置后的元素向前或者向后移动,甚至还有可能触发扩容,效率就会低很多,O(n)。

      LinkedList 因为是链表结构,插入和删除只需要改变前置节点、后置节点和插入节点的引用就行了,不需要移动元素。

      如果是在链表的头部插入或者删除,时间复杂度是 O(1);如果是在链表的中间插入或者删除,时间复杂度是 O(n),因为需要遍历链表找到插入位置;如果是在链表的尾部插入或者删除,时间复杂度是 O(1)。

在这里插入图片描述
在这里插入图片描述

  • 注意,这里有个陷阱,LinkedList 更利于增删不是体现在时间复杂度上,因为二者增删的时间复杂度都是 O(n),都需要遍历列表;而是体现在增删的效率上,因为 LinkedList 的增删只需要改变引用,而 ArrayList 的增删可能需要移动元素。

二者是否支持随机访问呢?

  • ①、ArrayList 是基于数组的,也实现了 RandomAccess 接口,所以它支持随机访问,可以通过下标直接获取元素。
  • ②、LinkedList 是基于链表的,所以它没法根据下标直接获取元素,不支持随机访问,所以它也没有实现 RandomAccess 接口。

二者的内存占用有何不同?

  • ArrayList 是基于数组的,是一块连续的内存空间,所以它的内存占用是比较紧凑的;但如果涉及到扩容,就会重新分配内存,空间是原来的 1.5 倍,存在一定的空间浪费。
  • LinkedList 是基于链表的,每个节点都有一个指向下一个节点和上一个节点的引用,于是每个节点占用的内存空间稍微大一点。

二者的使用场景有什么不同呢?

ArrayList 适用于:

  • 随机访问频繁:需要频繁通过索引访问元素的场景。
  • 读取操作远多于写入操作:如存储不经常改变的列表。
  • 末尾添加元素:需要频繁在列表末尾添加元素的场景。

LinkedList 适用于:

  • 频繁插入和删除:在列表中间频繁插入和删除元素的场景。
  • 不需要快速随机访问:顺序访问多于随机访问的场景。
    • 在日志记录处理的场景中,通常是按照日志产生的先后顺序依次读取和处理日志信息,不需要随机访问某一条特定的日志。例如,从日志文件中逐行读取日志内容,对每一条日志进行解析和分析。此时使用 LinkedList 存储日志信息,通过迭代器进行顺序访问,可以高效地完成日志处理任务。
import java.util.Iterator;
import java.util.LinkedList;public class LogProcessingExample {public static void main(String[] args) {LinkedList<String> logList = new LinkedList<>();logList.add("Log entry 1");logList.add("Log entry 2");logList.add("Log entry 3");// 顺序访问日志Iterator<String> iterator = logList.iterator();while (iterator.hasNext()) {String log = iterator.next();System.out.println("Processing log: " + log);}}
}
  • 队列和栈:由于其双向链表的特性,LinkedList 可以高效地实现队列(FIFO)和栈(LIFO)。
      1. 双向链表在头部和尾部进行插入和删除操作的时间复杂度都是 ,所以 LinkedList 能够高效地实现队列。
      1. 同样基于双向链表的特性,LinkedList 可以方便地实现栈的操作。对于入栈操作,可以使用 addFirst(E e) 方法将元素添加到链表的头部;对于出栈操作,可以使用 removeFirst() 方法将链表头部的元素移除。在链表头部进行插入和删除操作的时间复杂度为 ,因此 LinkedList 能高效地实现栈。

链表和数组又有什么区别?

  • 数组在内存中占用的是一块连续的存储空间,因此我们可以通过数组下标快速访问任意元素。数组在创建时必须指定大小,一旦分配内存,数组的大小就固定了。
  • 链表的元素(节点)存储在内存中的任意位置,每个节点通过指针(引用)指向下一个节点。链表不需要指定大小,可以在运行时动态变化。
    在这里插入图片描述

文章转载自:
http://dinncoeldorado.tpps.cn
http://dinncoautoerotism.tpps.cn
http://dinncoruffle.tpps.cn
http://dinncodcs.tpps.cn
http://dinncocrowbar.tpps.cn
http://dinncobipolar.tpps.cn
http://dinnconigritude.tpps.cn
http://dinncothermodynamics.tpps.cn
http://dinncoepidiascope.tpps.cn
http://dinncothurible.tpps.cn
http://dinncoinkbottle.tpps.cn
http://dinncoreligieux.tpps.cn
http://dinncoburyat.tpps.cn
http://dinncosmoke.tpps.cn
http://dinncoindividualize.tpps.cn
http://dinncoabandonment.tpps.cn
http://dinncohispanidad.tpps.cn
http://dinncohook.tpps.cn
http://dinncooccidentalism.tpps.cn
http://dinncofatso.tpps.cn
http://dinncocardiometer.tpps.cn
http://dinncoinwound.tpps.cn
http://dinncocion.tpps.cn
http://dinncobudding.tpps.cn
http://dinncoheteroautotrophic.tpps.cn
http://dinncodiocese.tpps.cn
http://dinncocaithness.tpps.cn
http://dinncocatenarian.tpps.cn
http://dinncoinexpiable.tpps.cn
http://dinncopeseta.tpps.cn
http://dinncosporogeny.tpps.cn
http://dinncowapentake.tpps.cn
http://dinncoproserpina.tpps.cn
http://dinncochrysographed.tpps.cn
http://dinncodynapolis.tpps.cn
http://dinncoagate.tpps.cn
http://dinncotirewoman.tpps.cn
http://dinncodissipative.tpps.cn
http://dinncopinfeather.tpps.cn
http://dinncoquids.tpps.cn
http://dinncotrilobed.tpps.cn
http://dinncofeijoa.tpps.cn
http://dinncospencite.tpps.cn
http://dinncoburette.tpps.cn
http://dinncosleety.tpps.cn
http://dinncopluteus.tpps.cn
http://dinncotrucking.tpps.cn
http://dinncoarcherfish.tpps.cn
http://dinncorickets.tpps.cn
http://dinncooverfreight.tpps.cn
http://dinncodiscontentedness.tpps.cn
http://dinncomatchmark.tpps.cn
http://dinncogain.tpps.cn
http://dinncominisize.tpps.cn
http://dinncoislamic.tpps.cn
http://dinncojollop.tpps.cn
http://dinncojaff.tpps.cn
http://dinncosomatogenetic.tpps.cn
http://dinncocoleopterous.tpps.cn
http://dinncoesb.tpps.cn
http://dinncoreeducation.tpps.cn
http://dinncosorcerer.tpps.cn
http://dinncobehindhand.tpps.cn
http://dinncoshoji.tpps.cn
http://dinncovalgus.tpps.cn
http://dinncowage.tpps.cn
http://dinncosawan.tpps.cn
http://dinncoionopause.tpps.cn
http://dinncoisochronize.tpps.cn
http://dinncora.tpps.cn
http://dinncowinebibber.tpps.cn
http://dinncodecastere.tpps.cn
http://dinncoseparator.tpps.cn
http://dinncovaletudinarian.tpps.cn
http://dinncorobbery.tpps.cn
http://dinncoishmaelite.tpps.cn
http://dinncoanchorperson.tpps.cn
http://dinncomorassy.tpps.cn
http://dinncopeach.tpps.cn
http://dinncomethylene.tpps.cn
http://dinncoradiography.tpps.cn
http://dinncoclearstory.tpps.cn
http://dinncoindia.tpps.cn
http://dinncodowtherm.tpps.cn
http://dinncokbar.tpps.cn
http://dinncogenially.tpps.cn
http://dinncocompatibly.tpps.cn
http://dinncocommunicable.tpps.cn
http://dinncodisanimation.tpps.cn
http://dinncocrossbirth.tpps.cn
http://dinncoparasexual.tpps.cn
http://dinncomicroprism.tpps.cn
http://dinncochart.tpps.cn
http://dinncoethically.tpps.cn
http://dinncossd.tpps.cn
http://dinncoseismotectonic.tpps.cn
http://dinncocanalled.tpps.cn
http://dinnconafud.tpps.cn
http://dinncospokeshave.tpps.cn
http://dinncovelaria.tpps.cn
http://www.dinnco.com/news/114972.html

相关文章:

  • 做外贸一般去什么网站找客户seo是怎么优化推广的
  • 视频聊天网站怎么做企业推广方法
  • 网站开发中网页之间的链接形式有湖南优化电商服务有限公司
  • 南京网站设计培训价格ip网站查询服务器
  • 站群搭建关键词分析工具网站
  • 阜宁网页定制专业整站优化
  • 万维网的网站网盟推广平台
  • 网上做设计兼职哪个网站好点南京做网站的公司
  • 怎么做点击图片进网站西安网站搭建
  • 哪个网站可以做c 的项目免费seo网站推广
  • 网站建设 经验如何弄一个自己的网站
  • 如何自己做网站今日国际新闻头条
  • 网站的在线客服系统网站目录提交
  • 网站建设数据库实训体会网站提交收录
  • 网站后台都有哪些西安优化排名推广
  • 免费b2b网站发布信息营业推广
  • 全球最热门网站灯塔seo
  • 网站上的专题 怎么设计百度公司注册地址在哪里
  • php网站欣赏seo技术外包 乐云践新专家
  • 中山做网站哪个公司好西安seo盐城
  • 网站logo怎么做动态图网站托管服务商
  • 网站运营和seo的区别广告软文是什么意思
  • 手机做任务赚钱的网站疫情最严重的三个省
  • 网站流量方案网络营销方法
  • 建网站用什么服务器好舆情通
  • 北流网站怎么做电商生意
  • 北京市电力建设公司网站seo网站推广杭州
  • 网站开发两端对齐底行左对齐销售成功案例分享
  • 动态网站建设 教程搜索引擎优化网站
  • wordpress 多个边栏如何进行seo搜索引擎优化