arraylist和linkedlist c#之间的性能 [英] performance between arraylist and linkedlist c#

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

问题描述



有人能告诉我arraylist和linkedlist之间的表现吗?谁更快?在哪种情况下使用arraylist和链接列表?



我在网上搜索但找不到合适的解决方案,例如,

如果任何人都知道或如果有人发现在网上使用完整的信息,那么也非常欢迎。



提前谢谢你。

Hi,
Can anybody tell me with good example that performance between arraylist and linkedlist?who is faster? and in which situation to use arraylist and linked List?

I searched on net but couldn't find proper solution with example,
If anyone knows or If anyone found use full info on net then also it is most welcome.

Thank you in advance.

推荐答案

然后我应该说你无法有效搜索。看看这些最能让你清楚的东西:

LinkedList和ArrayList之间有什么区别,什么时候使用哪一个? [ ^ ]

何时在数组/数组li上使用链表st? [ ^ ]
Then i should say you can't search efficiently.Look at these which will clear you most:
What is the difference between LinkedList and ArrayList, and when to use which one?[^]
When to use a linked list over an array/array list?[^]


我同意Ridoy的回复:你甚至没有真正搜索过CodeProject本身。



要真正得到一个有意义的答案,首先,必须使问题有意义。



具体来说,不同数据结构性能的实际比较(假设您有选择)需要基于其最常用(模态)用途,以及其他问题,如可伸缩性,内存使用和约束等。 。



如果你经常在数据结构中添加东西,并拔出第一个添加(fifo),或者添加最后一个(lifo):那是一个案例。如果你经常在以下任何地方进行随机插入和删除:collection / list / linked-list / queue / fifo-或lifo-stacks / circular-list / named pipes / btree,等等:那是另一个。



根据您的需要,您可能需要也可能不需要使用.NET的System.Collections.Generic命名空间提供的通用数据结构:[ ^ ],例如Queue< T> [ ^ ]。



也许您需要的是'ArrayList和System.Collections中的其他数据结构:如果您使用有关您的目标的更具体信息来澄清您的问题,您很可能会,获得好的建议,关注哪个方向。



无论如何,我强烈推荐这个由六部分组成的.NET数据结构概述:广泛的考试MSDN上的数据结构(由4guysfromrolla.com的Scott Mitchell编写):[ ^ ]。这个系列很久以前就写过了(在互联网时代),但我认为它非常值得用金。它确实涵盖了通用类型。
I agree with Ridoy's response: you have not really searched even CodeProject itself.

To really get a meaningful answer to your question, first, you have to make the question meaningful.

Specifically, real-world comparisons of performance of different data structures (assuming you have a choice) need to be based on their most frequent (modal) uses, and other issues like scalability, memory usage and constraints, etc.

If you most frequently are adding things to a data structure, and pulling out the first one added (fifo), or the last one added (lifo): that's one case. If you are frequently doing random insertions and deletions anywhere in: collection/list/linked-list/queue/fifo- or lifo- stacks/circular-list/named pipes/btree, and so on: that's another.

Depending on your needs, you may, or may not, need to use Generic data-structures offered by .NET's System.Collections.Generic namespace: [^], such as Queue<T> [^].

Perhaps all you need are 'ArrayList and other data-structures found in System.Collections: if you clarify your question with more specific information about what your goals are, you will, very possibly, get good advice, on which direction to follow.

In any case, I highly recommend this excellent six-part overview of .NET data-structures: "An Extensive Examination of Data Structures" on MSDN (written by Scott Mitchell of 4guysfromrolla.com): [^]. The series was written long ago (in internet time), but I think it is "worth its weight in gold." It does cover Generic Types.


除了其他答案:你不应该使用 ArrayList 。早在.NET Framework 2.0中引入泛型时,此集合就已过时。您应该在没有任何性能损失的情况下使用泛型类 System.Collections.Generic.List<> 。非泛型 ArrayList 需要潜在危险的类型转换。它没有被正式标记为过时,只是因为它在调试良好的旧程序集中使用时没有任何错误,但是对于使用非专用非泛型集合类的新开发根本没有意义。



-SA
In addition to other answers: you should not use ArrayList. This collection was rendered obsolete as early as of .NET Framework 2.0, when generics were introduced. You should use, without any performance loss, the generic class System.Collections.Generic.List<>. Non-generic ArrayList requires potentially dangerous type casts. It is not formally marked as obsolete just because there is nothing wrong in it if it is used in well debugged legacy assemblies, but for new development using non-specialized non-generic collection classes simply makes no sense.

—SA


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

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