当前位置:网站首页>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
边栏推荐
猜你喜欢
随机推荐
RL78开发环境
昨夜梦佳人,七夕试伊妆丨基于ModelArts实现AI妆容迁移丨【玩转华为云】
【C补充】指针相关知识点收集01
iMeta | Baidu certification is completed, search "iMeta" directly to the publisher's homepage and submission link
【C补充】指向指针或函数的指针
MySQL:完整性约束和 表的设计原则
Super Learning Method
mae,mse,rmse分别利用sklearn和numpy实现
转转测试环境的标签域名实践
Win11不识别蓝牙适配器的解决方法
线程必备内容
Mobile open source low code tools beeware and kivy
Mysql 存储引擎简介
JDBC知识点
语音社交app源码——具备哪些开发优势?
栈与队列的实现
HCIP 第十七天
VSCode学习资料
LeetCode简单题之最好的扑克手牌
[代码阅读] CycleGAN: Unpaired Image-To-Image Translation Using Cycle-Consistent Adversarial Networks