arraylist和linkedList之间的差异 [英] Difference between arraylist and linkedList

查看:115
本文介绍了arraylist和linkedList之间的差异的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


可能重复:

何时使用LinkedList<> over ArrayList<>?

何时在数组/数组列表上使用链表?

我应该什么时候使用arrayList和什么时候去LinkedList?

When should I use arrayList and when should I go for LinkedList?

我应该什么时候使用 TreeSet LinkedHashSet HashSet

When should I use TreeSet, LinkedHashSet and HashSet?

推荐答案

When should i use arrayList and when should I go for LinkedList?

Arraylist维护索引像数组。所以如果想要更频繁的获取操作比put然后arraylist是最好去。

Arraylist maintain indices like arrays. So if want more frequent get operations than put then arraylist is best to go.

LinkedList维护元素的指针。你不能像arraylist中的特定索引。但是在linkedlist中的优点是,它们不需要像在arraylist中那样来回移动来维护继续的索引。因此,在linkedlist中的获取操作是昂贵的,因为你必须通过指针来达到你的元素。但是put操作比arraylist好。你只需要连接到指针即可。

LinkedList maintain pointers to elements. you can't to a specific index like in arraylist. But the advantage here in linkedlist is that they don't need to shift back and forth like in arraylist to maintain continues indices. So get operations in linkedlist are costly as you would have to go through pointers to reach your elements. But put operations are good as compared to arraylist. you just need to connect to pointers and that's it.

When should I use TreeSet, LinkedHashSet and HashSet?

区别只在于排序。 treeet元素需要维护您的成员对象定义的特定顺序。

the difference is only in ordering. treeset elements need to maintain a specific orders defined by your member objects.

这篇关于arraylist和linkedList之间的差异的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆