c# - 字典、哈希集的访问时间

标签 c# dictionary

什么是访问时间:

  1. 在字典中查找一个值
  2. 检查一个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.

http://msdn.microsoft.com/en-us/library/xfhwa508.aspx

关于c# - 字典、哈希集的访问时间,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9057715/

相关文章:

python - 为嵌套字典中的每个键/值对返回最低值(和关联键)

java - 将 ID 列表与其对应的对象进行匹配

c# - 使用 C# 和 WMI 重命名打印机

c# - EPPLUS AutoFit 细胞

c# - 如何使用 LINQ to SQL 对时间序列中的数据进行二次采样?

python - 从 Ruby 到 Python - 是否有 "try"的等价物?

dictionary - 如何将由map创建的序列文件保留在hadoop中

c# - 将字典添加到另一个字典 C#

c# - Datagridview CellValueChanged 事件抛出 InvalidOperationException

python - 如何将具有多个值的字典写入 CSV?