当前位置:网站首页>arraylist之与linkedlist
arraylist之与linkedlist
2022-08-11 05:13:00 【SunForYou】
1 arraylist实现基于数组 linkedlist实现基于链表
2 随机访问get arraylist可以根据下标直接get linkedlist get 首先传入一个index,判断index是否大于linkedlist size的一半,如果不大于从前端遍历,如果大于从后端遍历,找到对应index元素,对于随机的get arraylist由于linkedlist
3 add和remove
arraylist尾部添加数据直接在尾部插入,在arraylist中间插入数据,插入位置之后的数据需要往后移动一位,插入数据时涉及到扩容机制,每次扩容后数组长度是扩容前的1.5倍,最大容量是Integer.value-8。
arraylist remove一个数据,remove位置之后的数据需要往前移动一位。
linkedlist尾部添加数据直接在原尾部元素的next指向新加的元素,在linkedlist中间add一个元素,需要把插入位置前后元素的next,pre重新指向。
linkedlist remove一个元素需要把remove位置前后的元素的next,pre重新指向
对于add和remove linkedlist由于arraylist.
边栏推荐
- 2022年Android面试中最常问的问题是什么?
- for循环使用多线程优化
- Switch and Router Technology - 36-Port Mirroring
- 【ARM】rk3399挂载nfs报错
- 一些常见mysql入门练习
- 2022 Quality Officer-Civil Construction Direction-General Basic (Quality Officer) Exam Mock 100 Questions and Online Mock Exam
- Switch and Router Technology-33-Static NAT
- Four functional interfaces
- UML基本概念——动态视图
- [FPGA tutorial case 49] Control case 1 - FPGA-based PID controller verilog implementation
猜你喜欢
随机推荐
面试宝典二:nlp常见知识点
[No 2022 Shanghai Security Officer A Certificate Exam Question Bank and Mock Exam
【无2022上海市安全员A证考试题库及模拟考试
Zabbix builds enterprise-level monitoring and alarm platform
ARM结构体系4:嵌入式硬件平台接口开发
你务必得明白——JSP的九大内置对象与四大域对象
Project Practice Lecture 27: Application of Status Mode in Duplicate Brands
redis集群模式--解决redis单点故障
FPGA engineer interview questions collection 111~120
Map根据key值排序
一些常见mysql入门练习
CentOS卸载Oracle 11gR2(x64)_转载
2022建筑焊工(建筑特殊工种)考题及模拟考试
0708作业---商品信息
代码在线审查(添加网页批注)的实现
MySQL索引
Network Skill Tree
Switch and Router Technology-27-OSPF Route Redistribution
金仓数据库 KingbaseGIS 使用手册(6.8. 几何对象输入函数)
2022 Quality Officer-Civil Construction Direction-General Basic (Quality Officer) Exam Mock 100 Questions and Online Mock Exam