English 中文(简体)
如何将List内部的工作联系起来?
原标题:How does LinkedList work internally in Java?

As far as I know, the concept of a linked list is a bunch of object connected to each other by having a next and sometimes previous attribute to traverse the objects.

我在贾瓦注意到,你可以制造一个有链接的List物体......但是,它像一个阵列/清单/序号一样,使用同样的方法,如:add()、get(等)。

因此,将List内部联系起来是否具有类似系列的顺序?

最佳回答

因此,将List内部联系起来是否具有类似系列的顺序?

页: 1 它是一系列私人开门类的事例<代码>。 条目,其中next,previouselement参引。 请注意,你本可以发现这一点,看一下与科索沃联合王公司有关的来源法。

这种内部结构没有暴露的原因,是它防止结构腐败,例如,它含有 lo。 通过<代码>List和 > 脱克接口的穿制服允许多变式使用。

问题回答

贾瓦的一位联系人的工作与你期望的那样。 如果您使用官方藏书LinkedList 。 然后,它确实会是a 并存交对方的物体,其次和有时是

是的,它有一个<代码>get(int index)方法,令人惊讶,因为这种方法不会非常有效,因为你需要从一开始就确定名单,以便找到第>第条目,而这并不是联系人所熟知的。 之所以如此,是因为联系人实施List接口。 这是你可以列举的。

However, you would probably try to avoid using a LinkedList when most of your access to it is through the get(int index) method as that would clearly be most inefficient. You would be perhaps better to use an ArrayList.

LinkedList is a chain of entities in which every entity knows about next-one, so get(index) operation requires iterating over this chain with counter. But this list optimized for adding and deleting by position (in case when I need to put element inside list or delete element from middle linked list performs better)

as i know linkedlist is like what you said in the first paragraph. each object has two references, called it s previous and it s next. unlike array which works sequentially (in C it s exactly stored in sequence. i think java just does the same, that s why we can t re-size an array), list works by referencing. so logically it works slower than array does.

有可能使用相关清单实施像阵列这样的物体。 与阵列相比,一些行动将更快,有些行动将较慢。 例如,在接近尾声的元素上打get(>)可能比与阵列相连接的清单慢得多。 但是,这仍然是可能的。

On the other hand, deleting an element from the middle of a linked list will be faster than the corresponding operation done using arrays.

Not really. Linked list is provided by the collection and by good design you could create a double linked list. Now it is not like array because these objects will not have indexes and are not elements within the container i.e. list. Hence you go through defining the next and previous and dictate what the next move is. They all have the same methods because again they are collections like i said.

因此,将List内部联系起来是否具有类似系列的顺序?

这份清单与《公约》有关。





相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签