Files
XCSDD/docs/api/containers/hashmap/contains.md
ssdfasd 58a83f445a fix: improve doc link navigation and tree display
- Fix link resolution with proper relative/absolute path handling
- Improve link styling with underline decoration
- Hide leaf nodes from tree, only show directories
- Fix log file path for packaged app
2026-03-19 12:44:08 +08:00

718 B

HashMap::Contains

bool Contains(const Key& key) const;

检查哈希表中是否包含指定的键。

参数:

  • key - 要检查的键

返回: 如果键存在返回 true,否则返回 false

复杂度: O(1) 平均,最坏 O(n)

示例:

XCEngine::Containers::HashMap<int, const char*> map;
map.Insert(1, "one");
map.Insert(2, "two");

if (map.Contains(1)) {
    std::cout << "Key 1 exists" << std::endl; // 输出 "Key 1 exists"
}

if (!map.Contains(99)) {
    std::cout << "Key 99 does not exist" << std::endl; // 输出 "Key 99 does not exist"
}

相关文档