更高效:Hashtable或List [英] More Efficient: Hashtable or List

查看:88
本文介绍了更高效:Hashtable或List的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




我的应用程序需要存储大量自定义对象,并且能够快速迭代它们。我想知道哪个数据结构

最有效,哈希表或通用列表。


使用枚举器来迭代数据结构好主意?


我会感激任何建议或建议,


谢谢

Macca

Hi,

My app needs to potentially store a large number of custom objects and be
able to iterate through them quickly. I was wondering which data structure
would be the most efficient to do this,a hashtable or a generic list.

Is using enumerators to iterate through the data structure a good idea?

I''d appreciate any suggesstions or advice,

Thanks
Macca

推荐答案

列表应该是更轻/更简单的对象,但为什么不使用该集合的最多

泛型类型是Arraylist。


当你说大的时候意味着它大于80 K?


再次为什么你需要一个集合为什么不使用一个静态数组,假设

自定义对象是相同的类型,并且数组的长度是已知的...作为

你可以通过装箱和需要知道集合存储对象

识别它们之前取消装箱..这是一项代价高昂的操作。


Nirosh。

" Macca" < Ma *** @ discussion.microsoft.com写信息

新闻:0D ************************* ********* @ microsof t.com ...
List should be the lighter/ simpler object, but why not you use the most
generic type of the collection that is Arraylist.

when you say large does that mean it is larger than 80 K ?

Again why you need a collection why not use a static array, assume that
custom objects are of same type and the length of the array is known.. as
you may know collection store object by boxing them and need to unbox before
recognizing them.. ,, which is a costly operation.

Nirosh.
"Macca" <Ma***@discussions.microsoft.comwrote in message
news:0D**********************************@microsof t.com...




我的应用程序需求可能存储大量自定义对象,并且能够快速迭代它们。我想知道哪个数据结构

最有效,哈希表或通用列表。


使用枚举器来迭代数据结构一个好主意?


我会感激任何建议或建议,


谢谢

Macca
Hi,

My app needs to potentially store a large number of custom objects and be
able to iterate through them quickly. I was wondering which data structure
would be the most efficient to do this,a hashtable or a generic list.

Is using enumerators to iterate through the data structure a good idea?

I''d appreciate any suggesstions or advice,

Thanks
Macca



再次使用枚举器通过集合进行迭代是建议的

方式..

Nirosh。

注意:在Generics过来之前将这个barior从收藏中删除

" Macca" < Ma *** @ discussion.microsoft.com写信息

新闻:0D ************************* ********* @ microsof t.com ...
again to itterate through a collection using enumerators is the recomended
way..
Nirosh.
Note: Until Generics come and remove this barior from collections later
"Macca" <Ma***@discussions.microsoft.comwrote in message
news:0D**********************************@microsof t.com...




我的应用程序需求可能存储大量自定义对象,并且能够快速迭代它们。我想知道哪个数据结构

最有效,哈希表或通用列表。


使用枚举器来迭代数据结构一个好主意?


我会感激任何建议或建议,


谢谢

Macca
Hi,

My app needs to potentially store a large number of custom objects and be
able to iterate through them quickly. I was wondering which data structure
would be the most efficient to do this,a hashtable or a generic list.

Is using enumerators to iterate through the data structure a good idea?

I''d appreciate any suggesstions or advice,

Thanks
Macca



如果要迭代动态长度数组,请使用List< T>

或ArrayList。如果你知道你正在迭代的

对象的类型,我推荐List< Tover ArrayList,否则ArrayList就可以了。


我更喜欢List<字典上的Tof ArrayList< Tor Hashtable,如果你不想使用密钥搜索你的对象。


进入迭代技术时,使用索引与使用IEnumerator for List< Tor ArrayList进行迭代相比,基于迭代的速度快50%-75%



因此,根据要求做出明智的选择。


-

问候,

Aditya.P

" Macca"写道:
If you want to iterate through an array of dynamic length use either List<T>
or ArrayList. I recomend List<Tover ArrayList if you know the type of the
objects that you are iterating through, else ArrayList would be fine.

I prefer List<Tof ArrayList over a Dictionary<Tor Hashtable in case you
do not want to search your objects using a key.

When coming to iteration technique, using index based iteration is 50%-75%
faster compared to iterating using IEnumerator for List<Tor ArrayList.

So make your choice wisely and based on the requirement.

--
Regards,
Aditya.P
"Macca" wrote:




我的应用程序需要存储大量自定义对象并且是

能够快速迭代它们。我想知道哪个数据结构

最有效,哈希表或通用列表。


使用枚举器来迭代数据结构一个好主意?


我会感激任何建议或建议,


谢谢

Macca
Hi,

My app needs to potentially store a large number of custom objects and be
able to iterate through them quickly. I was wondering which data structure
would be the most efficient to do this,a hashtable or a generic list.

Is using enumerators to iterate through the data structure a good idea?

I''d appreciate any suggesstions or advice,

Thanks
Macca


这篇关于更高效:Hashtable或List的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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