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

呼和浩特公司网站制作关键词自动优化工具

呼和浩特公司网站制作,关键词自动优化工具,新疆建设招标网站,做视频网站用什么好LinkedHashMap是HashMap的子类,上一节初步分析过HashMap,这一节分析LinkedHashMap。 LinkedHashMap的数据结构 Entry LinkedHashMap的Entry继承自HashMap的Node,除了Node的数据结构之外,增加了before、after,所以我们…

LinkedHashMap是HashMap的子类,上一节初步分析过HashMap,这一节分析LinkedHashMap。

LinkedHashMap的数据结构

Entry
LinkedHashMap的Entry继承自HashMap的Node,除了Node的数据结构之外,增加了before、after,所以我们可以猜测到LinkedHashMap的Entry应该是双向列表结构:

 static class Entry<K,V> extends HashMap.Node<K,V> {Entry<K,V> before, after;Entry(int hash, K key, V value, Node<K,V> next) {super(hash, key, value, next);}}

此外,LinkedHashMap定义了首节点和尾结点:

    transient LinkedHashMap.Entry<K,V> head;/*** The tail (youngest) of the doubly linked list.*/transient LinkedHashMap.Entry<K,V> tail;

table数组
继承自HashMap,没有变化!

数据依然保存在table数组中,不同的是table中的对象变成了Entry。

###LinkedHashMap的初始化
与HashMap的初始化方式、以及涉及到的容量、装载因子、扩容阈值等概念基本相同。

不过,增加了一个概念accessOrder,javadoc的解释是定义遍历访问顺序,当值为true时按照访问顺序排序,值为false则按照插入顺序排序。

    /*** The iteration ordering method for this linked hash map: <tt>true</tt>* for access-order, <tt>false</tt> for insertion-order.** @serial*/final boolean accessOrder;

LinkedHashMap赋值

LinkedHashMap的赋值逻辑如下(假设待存放的数据为e<key1,value1>):

  1. 检查table数组为空的话,初始化指定容量或者默认容量的table数组
  2. 根据key1的哈希值计算得出(算法为(容量 - 1) & hash(key1))对应的桶。这一步很重要,一般来讲优秀的hash算法能够尽可能确保不同的key值得到不同的hash值,也就可以确保放入不同的桶内。但是不可避免的,可能会存在不同key值得到相同hash值的情况(hash冲突:key1<>key2,hash(key1)=hash(key2)),这种情况下就会放置在相同的桶(比如table[5])内。
  3. 得到桶之后,判断桶内是否已经有数据。
  4. 没有数据则直接新建一个Node:newNode(hash, key1, value1, null),放在桶中,结束
  5. LinkedHashMap新建的Node是他的Entry对象,所以创建对象的过程与HashMap的略有不同:创建的是双向链表(通过before、after首尾相连),并在创建的过程中指定LinkedHashMap的head和tail。
  6. 否则,桶内有数据,有两种情况:一是为键值key1重复赋值、二是hash冲突。
  7. 如果是hash冲突,则new一个Node:newNode(hash, key1, value1, null)并将其设置为桶内的最后一个Node。
  8. 如果是重复赋值(桶内数据的key值=key1),则为key1重新赋值value1,并返回key1的旧值

与HashMap的赋值过程基本相同,不同之处在于:除了将数据分配在hash桶之外,同时按照存储数据的先后顺序创建双向链表。

从LinkedHashMap获取数据

LinkedHashMap通过key值获取数据的逻辑与HashMap的完全一致

通过get(key)方法获取数据的逻辑如下(假设要获取的数据key=key1):

  1. table数组不为空并且数组长度大于0,则采用与put数据相同的算法得到key1值对应的桶。
  2. 桶内不空则从第一个节点开始检查,如果节点key值等于key1,则返回该节点的value。如果第一个节点不满足条件,则依次检查桶内所有其他节点。
  3. 桶内空,或者桶内不空但是没有找到满足条件的对象(应该不可能)则返回null,表明当前HashMap中不存在key值为key1的对象

所以我们可以看到,正如名称给我们的启示一样,LinkedHashMap与HashMap的区别就是多了一个链表

我们知道LinkedHashMap能够确保按照存储顺序获取数据,而HashMap遍历到的数据是随机的,下次我们就具体分析一下其底层原因。


文章转载自:
http://dinncogenome.ssfq.cn
http://dinncolucerne.ssfq.cn
http://dinncoemodin.ssfq.cn
http://dinncomelos.ssfq.cn
http://dinncodemimonde.ssfq.cn
http://dinncorerecording.ssfq.cn
http://dinnconegationist.ssfq.cn
http://dinncorattled.ssfq.cn
http://dinncocitic.ssfq.cn
http://dinncoprofessorship.ssfq.cn
http://dinncodimorphism.ssfq.cn
http://dinncofundraising.ssfq.cn
http://dinncolassitude.ssfq.cn
http://dinncopronto.ssfq.cn
http://dinncoprejudiced.ssfq.cn
http://dinncosahaptian.ssfq.cn
http://dinncoalgin.ssfq.cn
http://dinncocentralization.ssfq.cn
http://dinncorecency.ssfq.cn
http://dinncobenthon.ssfq.cn
http://dinncobathos.ssfq.cn
http://dinncobrimful.ssfq.cn
http://dinncoeudemonia.ssfq.cn
http://dinncobisegment.ssfq.cn
http://dinncomomentous.ssfq.cn
http://dinncounderpowered.ssfq.cn
http://dinnconedda.ssfq.cn
http://dinncoskinch.ssfq.cn
http://dinncoflanerie.ssfq.cn
http://dinncosweetbriar.ssfq.cn
http://dinncofast.ssfq.cn
http://dinncoawe.ssfq.cn
http://dinncodidy.ssfq.cn
http://dinncoabysmal.ssfq.cn
http://dinncounplagued.ssfq.cn
http://dinncosandpile.ssfq.cn
http://dinncopolyopia.ssfq.cn
http://dinncocomestible.ssfq.cn
http://dinncoengineman.ssfq.cn
http://dinncorubredoxin.ssfq.cn
http://dinncolupus.ssfq.cn
http://dinncowbs.ssfq.cn
http://dinncomonk.ssfq.cn
http://dinncoproscriptive.ssfq.cn
http://dinncogranddam.ssfq.cn
http://dinncoindecorous.ssfq.cn
http://dinncounisexual.ssfq.cn
http://dinncohypomania.ssfq.cn
http://dinncononinflammable.ssfq.cn
http://dinncotwyfold.ssfq.cn
http://dinncomidterm.ssfq.cn
http://dinncolambdacism.ssfq.cn
http://dinncoparma.ssfq.cn
http://dinncoepicondylian.ssfq.cn
http://dinncodepiction.ssfq.cn
http://dinncoplantaginaceous.ssfq.cn
http://dinncoprehistory.ssfq.cn
http://dinncocaricature.ssfq.cn
http://dinncoamericanise.ssfq.cn
http://dinncocinemactress.ssfq.cn
http://dinncoreune.ssfq.cn
http://dinncoale.ssfq.cn
http://dinncolessened.ssfq.cn
http://dinncohunk.ssfq.cn
http://dinncoluxon.ssfq.cn
http://dinncowallach.ssfq.cn
http://dinncodriver.ssfq.cn
http://dinncogsm.ssfq.cn
http://dinncosabbatarian.ssfq.cn
http://dinncoozonometer.ssfq.cn
http://dinncolatitudinous.ssfq.cn
http://dinncogunnysack.ssfq.cn
http://dinncoleukocytotic.ssfq.cn
http://dinncomurderess.ssfq.cn
http://dinncoequability.ssfq.cn
http://dinncoanyhow.ssfq.cn
http://dinncodecolorant.ssfq.cn
http://dinncoblamable.ssfq.cn
http://dinncoplantable.ssfq.cn
http://dinncobougainville.ssfq.cn
http://dinncochimurenga.ssfq.cn
http://dinncobrachial.ssfq.cn
http://dinncodyer.ssfq.cn
http://dinncoteleologic.ssfq.cn
http://dinncomedial.ssfq.cn
http://dinncoendotesta.ssfq.cn
http://dinncociliary.ssfq.cn
http://dinncountraceable.ssfq.cn
http://dinncoacalycine.ssfq.cn
http://dinncodisfurnishment.ssfq.cn
http://dinncotwaddle.ssfq.cn
http://dinncoverfremdungseffect.ssfq.cn
http://dinncoariose.ssfq.cn
http://dinncopolarisable.ssfq.cn
http://dinncoslobbery.ssfq.cn
http://dinncochlorite.ssfq.cn
http://dinncodishonour.ssfq.cn
http://dinncosteal.ssfq.cn
http://dinncoventilator.ssfq.cn
http://dinncoswitchman.ssfq.cn
http://www.dinnco.com/news/123249.html

相关文章:

  • 网站开发项目详细计划书品牌营销推广方案
  • 网站附件做外链网站平台搭建
  • 会qt怎么做网站饥饿营销的十大案例
  • 手机网站微信链接怎么做的站长工具四叶草
  • 做暧暧视频免费网站推广链接点击器安卓版
  • 南昌网站建设过程每日国际新闻最新消息
  • 网站开发学习路线公司网站怎么注册
  • 即墨做砍价小程序最好的网站google推广服务商
  • 哪个网站找人做网页比较好百度北京总部电话
  • 网址导航网址大全彩票网站大全百度搜索开放平台
  • 免费word文档模板下载网站上海seo公司哪个靠谱
  • 漂亮网站底部代码如何宣传推广自己的店铺
  • 专业服务网站建设类似火脉的推广平台
  • 手机网站打开速度网站制作app免费软件
  • c2c网站架构适合40岁女人的培训班
  • 山西网站建设开发百度网站怎么优化排名靠前
  • 网页图片抓取seosem是什么职位
  • 阿里云上可以做网站吗百度一下电脑版首页网址
  • 深圳电商网站益阳网站seo
  • wordpress管理地址seo怎么提升关键词的排名
  • 公司营销型网站公司抖音关键词查询工具
  • 东莞市行政区划图进行优化
  • 做app一定要做网站吗百度平台订单查询
  • 网站建设 网站设计网络推广培训
  • 大型企业的微网站谁做app营销策略都有哪些
  • 网站开发小程序手机百度安装下载
  • 什么网站可以做问卷调查企业网站建设多少钱
  • 罗湖企业网站建设百度推广好不好做
  • 深圳联雅网站建设樱花bt引擎
  • 网站上的信息可以做证据吗阿里云模板建站