当前位置:网站首页>集合内之部原理总结
集合内之部原理总结
2022-08-09 06:29:00 【史上最强的弟子】
ArrayList
1. 构造方法
new Arraylist(size)
if size ==0 {}
else if size>0 new Object[size];
2. default CAPACITY 10
扩容:
1.构造方法进行扩容
2.add grow方法 1.5倍。
HashSet
1. 构造方法
Math.max((int) (c.size()/.75f) + 1, 16) 16 或者是 size/0.75 +1 这是为了离散分布。
2. 底层是hashmap 结构 map.put(e, PRESENT);
HashMap
1.自增因子是0.75
2.默认容量是16当HashMap中元素数超过容量*加载因子时,HashMap会进行扩容
Hash 避免冲突的方法:
1.开放地址法:开放定址法就是一旦发生了冲突,就去寻找下一个空的散列地址,只要散列表足够大,空的散列地址总能找到,并将记录存入 。
2.再哈希法:地址冲突了,进行地址再hash。
3.链地址法: 数组的节点延伸外部节点成为链表结构。
rehash()
0.75*size()
当哈希表中的条目数超出了加载因子与当前容量的乘积时,并且要存放的位置已经有元素了(hash碰撞),必须满足两个条件才会扩容。
增长量为2倍
ConcurrentHashMap
put 方法加锁锁的对象是hash 数组的node。
get 方法没有加锁,volatile 。
边栏推荐
猜你喜欢
The solution that does not work and does not take effect after VScode installs ESlint
使用百度EasyDL实现智能垃圾箱
Go lang1.18入门精炼教程——第一章:环境搭建
Likou Brush Question 180
移远EC20 4G模块拨号相关
Output method of list string print(*a) print(““.join(str(c) for c in a) )
Data center project preliminary summary
Altium designer软件常用最全封装库,包含原理图库、PCB库和3D模型库
带头双向循环链表的增删查改(C语言实现)
Adds, deletes, searches, and changes the leading doubly circular linked list (implemented in C language)
随机推荐
带头双向循环链表的增删查改(C语言实现)
kubernetes security
报错jinja2.exceptions.UndefinedError: ‘form‘ is undefined
22 high mid term paper topics forecast
Xilinx Zynq ZynqMP DNA
DevNet: Deviation Aware Networkfor Lane Detection
VB.net程序关闭后后台还在与SQL连接
数据库中间件-jdbi
简单工厂模式
Simple Factory Pattern
Service
[GO], arrays and slices
Unity C# 委托——事件,Action,Func的作用和区别
Use baidu EasyDL intelligent bin
cut命令的使用实例
shardingsphere data sharding configuration item description and example
SiO2 / KH550 modified ferroferric oxide nano magnetic particles | PDA package the ferromagnetic oxide nanoparticles (research)
Error: flask: TypeError: 'function' object is not iterable
中英文说明书丨CalBioreagents ACTH N端单克隆抗体
单例模式