OrderedDictionary的复杂性是什么? [英] What is the complexity of OrderedDictionary?

查看:379
本文介绍了OrderedDictionary的复杂性是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

没有人说OrderedDictionary有两个元素的副本,一个在散列表和列表中的其他,我不能在MSDN找到OrderedList的复杂度测量。

No one said that OrderedDictionary is having two copies of elements, one in a hashtable and other in a list, I can't find complexity measurements at MSDN for OrderedList.

感谢

推荐答案

查看

OrderedDictionary:IOrderedDictionary的通用实现

这个实现的有序的
字典是非常好的查找​​
操作:数组允许O(1)
通过索引查找,和散列表
允许O(1)通过键查找。然而,
需要保持数组
与hashtable同步
插入/删除操作具有
性能缺点执行
对数组的那些操作O(n)at
worst)。当然,还有
额外的内存需要存储
两个数据结构。因为这些
的缺点,OrderedDictionary
只应该使用插入/删除
操作将是最小和有
是需要有效地访问
元素的索引和/或键。

This implementation of an ordered dictionary is very good at lookup operations: the array allows O(1) lookups by index, and the hashtable allows O(1) lookups by key. However, the necessity of keeping the array synchronized with the hashtable means that insert/delete operations have the performance disadvantage of performing those operations on an array (O(n) at worst). There is also, of course, the extra memory requirement of storing both data structures. Because of these disadvantages, OrderedDictionary should only be used when insert/delete operations will be minimal and there is a need to efficiently access elements by index and/or key.

这篇关于OrderedDictionary的复杂性是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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