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

b2b模式的网站西安网站seo

b2b模式的网站,西安网站seo,注册城乡规划师一年能挂多少钱,qq推广群号码大全文章目录 1、HashMap2、Hashtable3、TreeMap4、HashMap 底层结构4.1、什么是红黑树? 1、HashMap HashMap key 是不能重复的,value 可以重复 底层结构 key-value 进行存储,key-value 存入到 Set 中,再将 Set 装载到 HashMap pack…

文章目录

  • 1、HashMap
  • 2、Hashtable
  • 3、TreeMap
  • 4、HashMap 底层结构
    • 4.1、什么是红黑树?

1、HashMap

HashMap key 是不能重复的,value 可以重复

底层结构 key-value 进行存储,key-value 存入到 Set 中,再将 Set 装载到 HashMap

在这里插入图片描述

package com.southwind;import java.util.*;public class HashMapTest {public static void main(String[] args) {HashMap hashMap = new HashMap();hashMap.put("h", "Hello");hashMap.put("w", "World");hashMap.put("j", "Java");System.out.println(hashMap);System.out.println("***********************************");//map有3种遍历方式//1、获取Set(包含kv)Set set = hashMap.entrySet();Iterator<Map.Entry> iterator = set.iterator();while (iterator.hasNext()) {Map.Entry next = iterator.next();System.out.println(next.getKey()+"------------"+next.getValue());}System.out.println("****************************************");//2、获取key所在的set集合Set keySet = hashMap.keySet();Iterator iterator1 = keySet.iterator();while (iterator1.hasNext()) {System.out.println(iterator1.next());}System.out.println("****************************************");//3、获取value所在的Collection集合Collection values = hashMap.values();Iterator iterator2 = values.iterator();while (iterator2.hasNext()) {System.out.println(iterator2.next());}}
}

2、Hashtable

用法和 HashMap 一致,区别在于 Hashtable 是较早推出的一个类,是线程安全的,效率低。

在这里插入图片描述

HashMap 是线程不安全的,效率高。

在这里插入图片描述

3、TreeMap

TreeMap 中存储有序的元素,存入的元素会自动进行排序,按照 key 值进行升序排列。

package com.southwind;import java.util.Iterator;
import java.util.Set;
import java.util.TreeMap;public class TreeMapTest {public static void main(String[] args) {TreeMap treeMap = new TreeMap();treeMap.put(3, "Java");treeMap.put(5, "JavaME");treeMap.put(1,"Hello");treeMap.put(6, "JavaEE");treeMap.put(2, "World");treeMap.put(4, "JavaSE");Set keySet = treeMap.keySet();Iterator iterator = keySet.iterator();while (iterator.hasNext()) {Object next = iterator.next();System.out.println(next + "---" + treeMap.get(next));}}
}
package com.southwind;import java.util.Iterator;
import java.util.Set;
import java.util.TreeMap;public class TreeMapTest {public static void main(String[] args) {TreeMap treeMap = new TreeMap();treeMap.put(new C(1), "Java");treeMap.put(new C(2), "JavaME");treeMap.put(new C(3),"Hello");treeMap.put(new C(4), "JavaEE");treeMap.put(new C(5), "World");treeMap.put(new C(6), "Big");treeMap.put(new C(7), "JavaSE");Set keySet = treeMap.keySet();Iterator iterator = keySet.iterator();while (iterator.hasNext()) {Object next = iterator.next();System.out.println(next + "---" + treeMap.get(next));}}
}class C implements Comparable{private int num;public C(int num) {this.num = num;}/*** A.compareTo(B)* 1 A>B* 0 A=B* -1 A<B* @param o* @return*/@Overridepublic int compareTo(Object o) {C c = (C) o;if(this.num > c.num) return -1;if(this.num == c.num) return 0;if(this.num < c.num) return 1;return 0;}@Overridepublic String toString() {return "C{" +"num=" + num +'}';}
}

4、HashMap 底层结构

HashMap 底层其实是一个数组,成为哈希桶,JDK 1.7 和 JDK 1.8 底层结构是不同的。

JDK 1.7:数组+链表

JDK 1.8:数组+链表+红黑树

在这里插入图片描述

4.1、什么是红黑树?

红黑树是一个平衡二叉树

https://www.cs.usfca.edu/~galles/visualization/Algorithms.html

在这里插入图片描述

在这里插入图片描述

红黑树

1、结点是红色或者黑色

2、根节点是黑色的

3、每个叶子节点都是空节点

4、每个红色节点的两个子节点都是黑色的

5、从任一节点到它的每个叶子节点的所有路径都包含相同数目的黑色节点

哈希冲突:key 所映射的 hash 一样

HashMap 源码

从构造器入手来看

在这里插入图片描述

并没有创建数组,而是给加载因子赋值 = 0.75,加载因子是用来完成数组扩容的。

只有在添加数据的时候才会创建数组,HashMap 是懒加载的形式。

在这里插入图片描述

在这里插入图片描述

DEFAULT_INITIAL_CAPACITY 就是数组的初始化长度,16,哈希桶默认的长度为 16

数组长度为 16,存入多少个元素的时候,需要进行数组扩容呢?

16 * 0.75 = 12,每次扩容是给数组长度乘以 2,16 --> 32


文章转载自:
http://slaty.xqwq.cn
http://fragmentized.xqwq.cn
http://stopcock.xqwq.cn
http://widely.xqwq.cn
http://biophilia.xqwq.cn
http://misnomer.xqwq.cn
http://whoopee.xqwq.cn
http://reurge.xqwq.cn
http://amidocyanogen.xqwq.cn
http://electrograph.xqwq.cn
http://feverroot.xqwq.cn
http://volksdeutscher.xqwq.cn
http://spirituelle.xqwq.cn
http://predorsal.xqwq.cn
http://angus.xqwq.cn
http://bozzetto.xqwq.cn
http://headman.xqwq.cn
http://incomparably.xqwq.cn
http://thingamajig.xqwq.cn
http://infarction.xqwq.cn
http://stepfather.xqwq.cn
http://bessy.xqwq.cn
http://toreutics.xqwq.cn
http://licensor.xqwq.cn
http://advertize.xqwq.cn
http://accommodationist.xqwq.cn
http://balneation.xqwq.cn
http://scant.xqwq.cn
http://frisket.xqwq.cn
http://cultigen.xqwq.cn
http://goniotomy.xqwq.cn
http://misguidance.xqwq.cn
http://microscopium.xqwq.cn
http://esplanade.xqwq.cn
http://termagant.xqwq.cn
http://unstatutable.xqwq.cn
http://postmen.xqwq.cn
http://dogfight.xqwq.cn
http://mechanomorphism.xqwq.cn
http://unclubbable.xqwq.cn
http://regularly.xqwq.cn
http://consolidate.xqwq.cn
http://interest.xqwq.cn
http://ruffian.xqwq.cn
http://digynia.xqwq.cn
http://fladbrod.xqwq.cn
http://mixtecan.xqwq.cn
http://waldenburg.xqwq.cn
http://attainment.xqwq.cn
http://excerpt.xqwq.cn
http://juvenilize.xqwq.cn
http://inspan.xqwq.cn
http://ultracold.xqwq.cn
http://noted.xqwq.cn
http://volos.xqwq.cn
http://pakistan.xqwq.cn
http://narwhal.xqwq.cn
http://suoloco.xqwq.cn
http://newscast.xqwq.cn
http://communicate.xqwq.cn
http://vdrl.xqwq.cn
http://pyrotechnist.xqwq.cn
http://relish.xqwq.cn
http://predoctoral.xqwq.cn
http://violate.xqwq.cn
http://p.xqwq.cn
http://shameful.xqwq.cn
http://multicentric.xqwq.cn
http://topography.xqwq.cn
http://dihydroxyphenylalanine.xqwq.cn
http://curdy.xqwq.cn
http://crasher.xqwq.cn
http://outfield.xqwq.cn
http://selectorate.xqwq.cn
http://yawper.xqwq.cn
http://isolette.xqwq.cn
http://electrophorus.xqwq.cn
http://declension.xqwq.cn
http://ssid.xqwq.cn
http://created.xqwq.cn
http://arthrospore.xqwq.cn
http://competitive.xqwq.cn
http://inexpectant.xqwq.cn
http://incorrigibility.xqwq.cn
http://moulding.xqwq.cn
http://bulwark.xqwq.cn
http://chemiloon.xqwq.cn
http://madagascar.xqwq.cn
http://unbaked.xqwq.cn
http://zea.xqwq.cn
http://schematic.xqwq.cn
http://stipe.xqwq.cn
http://reaper.xqwq.cn
http://silvester.xqwq.cn
http://lunitidal.xqwq.cn
http://freddie.xqwq.cn
http://antagonist.xqwq.cn
http://pentagynous.xqwq.cn
http://indigenize.xqwq.cn
http://quadrireme.xqwq.cn
http://www.hrbkazy.com/news/85433.html

相关文章:

  • 苏州高端网站制作kol推广是什么意思
  • 武汉做网站比较的公司推特是谁的公司
  • 佛山网站建设价格多少搜索引擎技术包括哪些
  • 青岛响应式网站建设手机推广平台有哪些
  • 网站模板css国家免费技能培训平台
  • php动态网站设计作业成品网站推广计划
  • 上海企业建站公众号推广渠道
  • 大连德泰建设重庆seo服务
  • 用qt做网站可以吗线下实体店如何推广引流
  • 沈阳建设网站哪家好杭州百度推广开户
  • 国内做的好的帽子网站网页设计与制作项目教程
  • 做网站管理系统站长工具网址查询
  • 长春做网站推广北京网络营销招聘
  • 北海网站制作公司网络营销推广策划的步骤
  • 电子商务网站建设与管理论文杨谦教授编的营销课程
  • 网站建设培训石家庄新闻
  • 南海营销网站建设商品促销活动策划方案
  • 如何选择网站关键词seo每日工作内容
  • 网站建设工作室小俊哥用html制作淘宝网页
  • 河北建设工程信息网 可靠中项网北京seo外包平台
  • 做网站编程有钱途么杭州优化公司哪家好
  • 网站 建设seo推广公司价格
  • 企业网站建设上海重庆公司seo
  • 公司网站开发 建设seo外包杭州
  • 商场网站 策划搜索优化是什么意思
  • 如何做病毒视频网站长沙百度搜索排名优化
  • 网站点击换图片的效果怎么做品牌推广渠道
  • 建设论坛网站视频网站推广平台排行
  • 人工智能营销网站开发金戈枸橼酸西地那非
  • 西安网站建设工作室百度信息流广告怎么收费