ArrayList与Linked性能分析
来源:互联网 发布:谷歌seo外链博客 编辑:程序博客网 时间:2024/05/17 02:42
插入/删除:
首尾插入时LinkedList效率更高,指定索引位置插入的话就不一定了,因为ArrayList可能会导致对象移位或者扩容复制,LinkedList需要先查找到index前的对象;
查找:
首尾查找效率都很高
指定索引查找的话ArrayList完胜
遍历:
用迭代器遍历的话效率都差不多
public class TestGetMethod { public static void main(String[] args) { List<String> al = new ArrayList<String>(); List<String> ll = new LinkedList<String>(); int count = 1000000; for(int i=0; i<count; i++) { al.add(""); ll.add(""); } long ts = System.currentTimeMillis(); for(String s: al) { } long te = System.currentTimeMillis(); System.out.println("al iterator spend time:" + (te-ts)); ts = System.currentTimeMillis(); for(String s: ll) { } te = System.currentTimeMillis(); System.out.println("ll iterator spend time:" + (te-ts)); ts = System.currentTimeMillis(); for(int i=0; i<count; i++) { al.get(i); } te = System.currentTimeMillis(); System.out.println("al get spend time:" + (te-ts)); ts = System.currentTimeMillis(); for(int i=0; i<count; i++) { ll.get(i); } te = System.currentTimeMillis(); System.out.println("ll get spend time:" + (te-ts)); }}
0 0
- ArrayList与Linked性能分析
- ArrayList和Linked的分析
- Java中arraylist和linkedlist源码分析与性能比较
- Java ArrayList 源码分析与提高性能替代方案
- ArrayList和LinkedList性能分析
- ArrayList LinkedList源码分析,性能分析
- ArrayList 与 LinkedList性能比较
- HashSet与ArrayList性能测试
- Java 深入学习(2) —— ArrayList、LinkedList、Vector 应用场景与性能分析
- Linklist和Arraylist的性能分析
- ArrayList和LinkedList性能比较分析
- ArrayList与LinkedList源码分析
- LinkedList 与ArrayList的性能差异
- List<T> 与ArrayList 性能比较
- java中ArrayList与LinkedList性能测试
- LinkedList与ArrayList的性能比较
- java性能优化-Arraylist与Linkedlist整改查性能比较
- ArrayList用法详解与源码分析
- .Net 多线程之Timer的应用
- iOS 第三方库
- ceph存储 Linux/Unix下pid文件作用浅析
- sed系列:多命令执行
- java.lang.OutOfMemoryError: Java heap space解决方法
- ArrayList与Linked性能分析
- POJ 1722 SUBTRACT(DP)
- java注释的关键字的详解
- iOS7滑动返回
- java判断字符串是否为空的方法总结
- 微博用户影响力分析
- linux 学习之九、Linux 磁盘与文件系统管理(1)
- toString()
- IOS 6 自动布局 入门-1