Files
XCSDD/docs/api/containers/array/array.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

68 lines
1.8 KiB
Markdown

# Array
**命名空间**: `XCEngine::Containers`
**类型**: `class` (template)
**描述**: 模板动态数组容器,提供自动扩容的数组实现。
## 概述
`Array<T>` 是一个模板动态数组容器,提供了类似 `std::vector` 的功能,但针对游戏引擎进行了优化。
## 类型别名
| 别名 | 类型 | 描述 |
|------|------|------|
| `Iterator` | `T*` | 迭代器类型 |
| `ConstIterator` | `const T*` | 常量迭代器类型 |
## 公共方法
| 方法 | 描述 |
|------|------|
| [Constructor](constructor.md) | 构造数组实例 |
| [Copy/Move Constructor](copy-move-constructor.md) | 拷贝或移动构造 |
| [Destructor](destructor.md) | 析构函数 |
| [operator=](operator-assign.md) | 赋值运算符 |
| [operator[]](operator-subscript.md) | 下标访问 |
| [Data](data.md) | 获取原始数据指针 |
| [Front/Back](front-back.md) | 获取首/尾元素引用 |
| [Size/Capacity/Empty](size.md) | 获取尺寸信息 |
| [Clear](clear.md) | 清空所有元素 |
| [Reserve](reserve.md) | 预留容量 |
| [Resize](resize.md) | 调整大小 |
| [PushBack](pushback.md) | 尾部添加(拷贝/移动) |
| [EmplaceBack](emplaceback.md) | 就地构造尾部添加 |
| [PopBack](popback.md) | 尾部移除 |
| [begin/end](iterator.md) | 获取迭代器 |
| [SetAllocator](setallocator.md) | 设置内存分配器 |
## 使用示例
```cpp
#include <XCEngine/Containers/Array.h>
// 基本用法
XCEngine::Containers::Array<int> arr;
arr.PushBack(1);
arr.PushBack(2);
arr.PushBack(3);
// 使用 initializer_list
XCEngine::Containers::Array<int> arr2 = {1, 2, 3, 4, 5};
// 迭代
for (auto& elem : arr) {
printf("%d\n", elem);
}
// 使用 EmplaceBack
arr.EmplaceBack(4);
```
## 相关文档
- [HashMap](../hashmap/hashmap.md) - 哈希表容器
- [Memory 模块](../../memory/memory.md) - 内存分配器