List< T>链表? [英] Is List<T> a linked list?

查看:95
本文介绍了List< T>链表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

System.Collections.Generic.List< T> 的一种由数组支持-本质上是.NET 1.0中 ArrayList 的通用版本。从文档中:


List< T> 类与 ArrayList 类。它使用大小根据需要动态增加的数组实现 IList< T> 通用接口。


请注意,由于有数组支持,因此它通过索引器的访问是O(1),而不是链接列表的O(N)。



如果要链接列表,请使用 LinkedList< T> 。请注意,这是一个双重链接的列表。我不相信.NET会公开单独链接的列表类型。


Is System.Collections.Generic.List<T> a type of linked list(not the LinkedList<T> class)?

A linked list is a data structure consisting of a group of nodes which together represent a sequence. Under the simplest form, each node is composed of a datum and a reference (in other words, a link) to the next node in the sequence.


A linked list whose nodes contain two fields: an integer value and a link to the next node.
The last node is linked to a terminator used to signify the end of the list.

wikipedia.org

If it is, what kind of linked list is it?

解决方案

No, List<T> is backed by an array - it's essentially a generic version of ArrayList from .NET 1.0. From the docs:

The List<T> class is the generic equivalent of the ArrayList class. It implements the IList<T> generic interface using an array whose size is dynamically increased as required.

Note that due to being backed by an array, its access via indexers is O(1) as opposed to the O(N) for a linked list.

If you want a linked list, use LinkedList<T>. Note that this is a doubly-linked list. I don't believe .NET exposes a singly-linked list type.

这篇关于List&lt; T&gt;链表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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