Java:集合和'数据结构'之间的差异 [英] Java: Difference Between a collection and 'Data Structure'

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

问题描述

在Java中,我不了解集合与数据结构。在我看来,集合引用列表,集合,映射,队列和'数据结构'是指用于实现集合的数据结构,如数组,链表或树。例如ArrayList和LinkedList都是集合,但它们的数据结构分别是一个数组和一个链表。

In Java, I don't understand a collection vs a 'data structure'. It seems to me that collection refers to list, set, map, queue, and 'data structure' refers to the data structure used to implement the collection such as an array, linked list, or tree. For example ArrayList and LinkedList are both collection, but their data structure are respectively an array, and a linked list. Am I correct, or am I confusing terms?

推荐答案

数据结构是数据在内存中的存储内部表示的方式。集合是如何访问它。我强调可以这个词。

A data structure is how the data is represented inside the storage in memory. A collection is how it can be accessed. I stress on the word "can".

如果您将数据存储在LinkedList中并排序,性能将下降。相同的算法如果使用ArrayList的性能会提高。

If you store data in a LinkedList and sort it, the performance will drop. The same algorithm if you use a ArrayList the performance will enhance. Just by changing the way its represented in memory will help various factors.

你可以使用集合表示来访问它,你也可以使用index访问数据。你也可以去getFirst,getNext,getPrev。

You "can" access it using a collection representation, you "can" also use the "index" to access the data. You "can" also go getFirst, getNext, getPrev.

你的困惑在于内部存储和访问存储之间。分开2。

Your confusion is between internal storage and accessing the storage. Separate the 2.

这篇关于Java:集合和'数据结构'之间的差异的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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