当前位置:网站首页>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
边栏推荐
- ThreadLocal详细分析
- Mysql 存储引擎简介
- 《迁移学习导论》第2版,升级内容抢先看!
- 无代码平台单项选择入门教程
- There are 12 balls, including 11 weight, only one, don't know is light or heavy. Three times in balance scales, find out the ball.
- 栈与队列的实现
- 开源一夏|ArkUI如何自定义弹窗(eTS)
- Jenkins使用手册(1) —— 软件安装
- 有12个球,其中11个重量相等,只有1个不一样,不知是轻还是重.用天平秤三次,找出这个球.
- 高级转录组分析和R数据可视化火热报名中(2022.10)
猜你喜欢
随机推荐
密码字典生成工具pydictor/john
Win11不识别蓝牙适配器的解决方法
Rust 入门指南 (用 WASM 开发第一个 Web 页面)
mysql进阶(二十六)MySQL 索引类型
bash shell数组详解
HCIP 第十七天
为企业数字化转型提供服务_数字赋能企业转型
KubeDNS 和 CoreDNS
Apache Calcite 框架原理入门和生产应用
IDEA启动热部署
Multimedia and Internet of Things technology make the version "live" 129 vinyl records "Centennial Voice"
2万字50张图玩转Flink面试体系
Mysql应用日志时间与系统时间相差八小时
MySQL核心SQL:结构化查询语句SQL、库操作、表操作、CRUD
数据万象内容审核 — 共建安全互联网,专项开展“清朗”直播整治行动
zabbix部署
[论文翻译] Unpaired Image-to-Image Translation using Adversarial Consistency Loss
Acwing 3208. Z字形扫描 偏移量+扩展图
在测试集上训练,还能中CVPR?这篇IEEE批判论文是否合理?
redis解决分布式session问题









