可能的重复:
何时使用 LinkedList 而不是 ArrayList? https://stackoverflow.com/questions/322715/when-to-use-linkedlist-over-arraylist
何时在数组/数组列表上使用链表? https://stackoverflow.com/questions/393556/when-to-use-a-linked-list-over-an-array-array-list
什么时候应该使用 arrayList,什么时候应该使用 LinkedList?
我应该什么时候使用TreeSet
, LinkedHashSet
and HashSet
?
When should i use arrayList and when should I go for LinkedList?
Arraylist 像数组一样维护索引。因此,如果想要比 put 更频繁的 get 操作,那么最好使用 arraylist。
LinkedList 维护指向元素的指针。你不能像 arraylist 那样指向特定的索引。但链表的优点是它们不需要像数组列表那样来回移动来维护连续索引。因此,链表中的获取操作成本很高,因为您必须通过指针才能到达元素。但与 arraylist 相比,put 操作更好。您只需要连接到指针即可。
When should I use TreeSet, LinkedHashSet and HashSet?
区别仅在于顺序。树集元素需要维护由成员对象定义的特定顺序。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)