当前位置:网站首页>集合内之部原理总结
集合内之部原理总结
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 。
边栏推荐
猜你喜欢
Search 1688 product interface by image (item_search_img-search 1688 product by image (Politao interface) code docking tutorial
MYSQL Advanced Chapter - Query Interception Analysis, Lock Mechanism, Master-Slave Replication
Error jinja2.exceptions.UndefinedError: 'form' is undefined
缓存技术使用
pdf加密、找回密码
中英文说明书丨TRC D-阿卓糖(D-Altrose)
ZIP压缩包文件删除密码的方法
移远EC20 4G模块拨号相关
e-learning summary
workbench 数据导出
随机推荐
kubernetes security
Introduction and use of BeautifulSoup4
VS2019 common shortcut keys
TCP segment of a reassembled PDU
报错jinja2.exceptions.UndefinedError: ‘form‘ is undefined
治疗消化性溃疡—Toronto Research Chemicals 甘氨酸铝
C language implements sequential stack and chain queue
CalBioreagents超全Id 蛋白兔单克隆抗体,助力科研
BeautifulSoup4的介绍与使用
普罗米修斯原理及节点发布
APP商品详情源数据接口(淘宝/京东/拼多多/苏宁/抖音等平台详情数据分析接口)代码对接教程
语句加锁分析
P7阿里面试题2020.07 之滑动窗算法(阿里云面试)
[R language] Extract all files under a folder to a specific folder
How to find package information and pin definitions for NXP S32K1xx series microcontrollers
【R语言】交互作用 测试数据
redis 运行lua 脚本 出现Invalid argument(s)
APP product source data interface (taobao, jingdong/spelling/suning/trill platform details a lot data analysis interface) code and docking tutorial
【R语言】对文件进行归一化整理到各文件类型文件夹
Cysteine/Galactose/Perylenediimide Functionalized Fe3O4 Fe3O4 Nanomaterials | Scientific Research Reagents