什么是访问时间:
- 在字典中查找一个值
- 检查一个HashSet是否有值
它是不是像 C++0x 的 unordered_map 那样复杂度为 O(1)?
最佳答案
是的,当您使用 Contains 方法或 Dictionary 的索引器时。
来自文档:
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.
关于c# - 字典、哈希集的访问时间,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9057715/