当前位置:网站首页>Difference between ArrayList and LinkedList
Difference between ArrayList and LinkedList
2022-08-04 10:31:00 【T.Mss】
ArrayList
Extension mechanism
ArrayList() will use a zero-length array
ArrayList(int initialCapacity) will use an array with the specified capacity
public ArrayList(Collectionc) will use the size of c as the array capacity
add(Object o) expands to 10 for the first time, and then expands to 1.5 times the last time
addAll(Collection c) When there are no elements, the expansion is Math.max(10, the actual number of elements), and if there are elements, the expansion is Math.max (1.5 times the original capacity, the actual number of elements)
Features
1. Array-based, requires contiguous memory
2. Fast random access (access according to the specified subscript)
3. Tail insertion, deletion performance is OK, other parts insertion and deletion will move data, so the performance will be low
4. Can use cpu cache, locality principle
LinkedList
Features
1. Based on doubly linked list, no need for contiguous memory (each bit has a pointer to the next)
2. Random access is slow (traverse along the linked list)
3. High performance of head and tail insertion and deletion
4. Occupies a lot of memory
边栏推荐
猜你喜欢
随机推荐
Mobile open source low code tools beeware and kivy
在测试集上训练,还能中CVPR?这篇IEEE批判论文是否合理?
C语言*小白的探险历程
C#/VB.NET:在 Word 中设置文本对齐方式
云计算适合什么企业_当前全球云计算处于发展
Introduction to Mysql storage engine
粤黔协作,山海同心!578种贵州特色农产品走进粤港澳大湾区
学习在php中将特大数字转成带有千/万/亿为单位的字符串
usb设备复合g_webcam摄像头码流传输功能以及g_serial串口功能
华为云安全云脑,让企业云化运营更放心
Win11怎么进行左右键对调?
无代码平台数字入门教程
物体颜色的来源
[代码阅读] CycleGAN: Unpaired Image-To-Image Translation Using Cycle-Consistent Adversarial Networks
Jina 实例秀|基于神经搜索的网络安全威胁检测(一)
高级转录组分析和R数据可视化火热报名中(2022.10)
二叉树的基础练习
微信小程序自定义组件-城市选择「建议收藏」
标准C语言学习总结12
Google Earth Engine APP——实现ui.Select() 的设定和条件判断