Files
XCSDD/docs/api/containers/hashmap/copy-move.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

35 lines
904 B
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# HashMap::Copy/Move 构造
```cpp
HashMap(const HashMap& other);
HashMap(HashMap&& other) noexcept;
```
拷贝构造和移动构造。
**参数:**
- `other` - 源哈希表(拷贝版本为 `const` 引用,移动版本为右值引用)
**返回:** 无(构造函数)
**复杂度:**
- 拷贝构造O(m_bucketCount + other.m_size)
- 移动构造O(m_bucketCount),移动构造需要遍历所有桶以重新建立桶的指针关系
**示例:**
```cpp
XCEngine::Containers::HashMap<int, std::string> map1;
map1.Insert(1, "hello");
map1.Insert(2, "world");
XCEngine::Containers::HashMap<int, std::string> map2(map1); // 拷贝构造
XCEngine::Containers::HashMap<int, std::string> map3(std::move(map1)); // 移动构造map1 在此调用后状态不确定
```
## 相关文档
- [HashMap 总览](hashmap.md) - 返回类总览
- [operator=](operator-assign.md) - 赋值运算符