Dictionary,HashSet的访问时间 [英] Access times for Dictionary, HashSet
问题描述
- 查找字典中的值
- 检查是否HashSet有一个值
它是O(1)像C ++ 0x的unordered_map吗?
$ b $是的,当您使用Contains方法或Dictionary的索引器时。从文档:
字典(TKey,TValue)通用类提供从一组键到一组值的映射。字典中的每个添加都包含一个值及其关联的键。通过使用其键来获取值非常快,接近于O(1),因为Dictionary(Of TKey,TValue)类被实现为哈希表。
http://msdn.microsoft.com/en -us / library / xfhwa508.aspx
What are the access times for:
- Looking up a value in Dictionary
- Check whether a HashSet has a value
Is it O(1) like unordered_map of C++0x?
Yes, when you use the Contains method or the indexer of the Dictionary.
From the docs:
The Dictionary(Of TKey, TValue) generic class provides a mapping from a set of keys to a set of values. Each addition to the dictionary consists of a value and its associated key. Retrieving a value by using its key is very fast, close to O(1), because the Dictionary(Of TKey, TValue) class is implemented as a hash table.
http://msdn.microsoft.com/en-us/library/xfhwa508.aspx
这篇关于Dictionary,HashSet的访问时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!