docs: 重构 API 文档结构并修正源码准确性
- 重组文档目录结构: 每个模块的概述页移动到模块子目录
- 重命名 index.md 为 main.md
- 修正所有模块文档中的错误:
- math: FromEuler→FromEulerAngles, TransformDirection 包含缩放, Box 是 OBB, Color::ToRGBA 格式
- containers: 新增 operator==/!= 文档, 补充 std::hash DJB 算法细节
- core: 修复 types 链接错误
- debug: LogLevelToString 返回大写, timestamp 是秒, Profiler 空实现标注, Windows API vs ANSI
- memory: 修复头文件路径, malloc vs operator new, 新增方法文档
- resources: 修复 Shader/Texture 链接错误
- threading: TaskSystem::Wait 空实现标注, ReadWriteLock 重入描述, LambdaTask 链接
- 验证: fix_links.py 确认 0 个断裂引用
2026-03-19 00:22:30 +08:00
|
|
|
# Array
|
|
|
|
|
|
|
|
|
|
**命名空间**: `XCEngine::Containers`
|
|
|
|
|
|
|
|
|
|
**类型**: `class` (template)
|
|
|
|
|
|
2026-03-20 02:35:01 +08:00
|
|
|
**头文件**: `XCEngine/Containers/Array.h`
|
|
|
|
|
|
docs: 重构 API 文档结构并修正源码准确性
- 重组文档目录结构: 每个模块的概述页移动到模块子目录
- 重命名 index.md 为 main.md
- 修正所有模块文档中的错误:
- math: FromEuler→FromEulerAngles, TransformDirection 包含缩放, Box 是 OBB, Color::ToRGBA 格式
- containers: 新增 operator==/!= 文档, 补充 std::hash DJB 算法细节
- core: 修复 types 链接错误
- debug: LogLevelToString 返回大写, timestamp 是秒, Profiler 空实现标注, Windows API vs ANSI
- memory: 修复头文件路径, malloc vs operator new, 新增方法文档
- resources: 修复 Shader/Texture 链接错误
- threading: TaskSystem::Wait 空实现标注, ReadWriteLock 重入描述, LambdaTask 链接
- 验证: fix_links.py 确认 0 个断裂引用
2026-03-19 00:22:30 +08:00
|
|
|
**描述**: 模板动态数组容器,提供自动扩容的数组实现。
|
|
|
|
|
|
|
|
|
|
## 概述
|
|
|
|
|
|
|
|
|
|
`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) | 赋值运算符 |
|
2026-03-19 02:01:18 +08:00
|
|
|
| [operator[]](operator-subscript.md) | 下标访问 |
|
docs: 重构 API 文档结构并修正源码准确性
- 重组文档目录结构: 每个模块的概述页移动到模块子目录
- 重命名 index.md 为 main.md
- 修正所有模块文档中的错误:
- math: FromEuler→FromEulerAngles, TransformDirection 包含缩放, Box 是 OBB, Color::ToRGBA 格式
- containers: 新增 operator==/!= 文档, 补充 std::hash DJB 算法细节
- core: 修复 types 链接错误
- debug: LogLevelToString 返回大写, timestamp 是秒, Profiler 空实现标注, Windows API vs ANSI
- memory: 修复头文件路径, malloc vs operator new, 新增方法文档
- resources: 修复 Shader/Texture 链接错误
- threading: TaskSystem::Wait 空实现标注, ReadWriteLock 重入描述, LambdaTask 链接
- 验证: fix_links.py 确认 0 个断裂引用
2026-03-19 00:22:30 +08:00
|
|
|
| [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) | 尾部移除 |
|
2026-03-20 02:35:01 +08:00
|
|
|
| [begin/end](begin-end.md) | 获取迭代器 |
|
docs: 重构 API 文档结构并修正源码准确性
- 重组文档目录结构: 每个模块的概述页移动到模块子目录
- 重命名 index.md 为 main.md
- 修正所有模块文档中的错误:
- math: FromEuler→FromEulerAngles, TransformDirection 包含缩放, Box 是 OBB, Color::ToRGBA 格式
- containers: 新增 operator==/!= 文档, 补充 std::hash DJB 算法细节
- core: 修复 types 链接错误
- debug: LogLevelToString 返回大写, timestamp 是秒, Profiler 空实现标注, Windows API vs ANSI
- memory: 修复头文件路径, malloc vs operator new, 新增方法文档
- resources: 修复 Shader/Texture 链接错误
- threading: TaskSystem::Wait 空实现标注, ReadWriteLock 重入描述, LambdaTask 链接
- 验证: fix_links.py 确认 0 个断裂引用
2026-03-19 00:22:30 +08:00
|
|
|
| [SetAllocator](setallocator.md) | 设置内存分配器 |
|
|
|
|
|
|
|
|
|
|
## 使用示例
|
|
|
|
|
|
|
|
|
|
```cpp
|
|
|
|
|
#include <XCEngine/Containers/Array.h>
|
|
|
|
|
|
|
|
|
|
// 基本用法
|
2026-03-19 00:49:08 +08:00
|
|
|
XCEngine::Containers::Array<int> arr;
|
docs: 重构 API 文档结构并修正源码准确性
- 重组文档目录结构: 每个模块的概述页移动到模块子目录
- 重命名 index.md 为 main.md
- 修正所有模块文档中的错误:
- math: FromEuler→FromEulerAngles, TransformDirection 包含缩放, Box 是 OBB, Color::ToRGBA 格式
- containers: 新增 operator==/!= 文档, 补充 std::hash DJB 算法细节
- core: 修复 types 链接错误
- debug: LogLevelToString 返回大写, timestamp 是秒, Profiler 空实现标注, Windows API vs ANSI
- memory: 修复头文件路径, malloc vs operator new, 新增方法文档
- resources: 修复 Shader/Texture 链接错误
- threading: TaskSystem::Wait 空实现标注, ReadWriteLock 重入描述, LambdaTask 链接
- 验证: fix_links.py 确认 0 个断裂引用
2026-03-19 00:22:30 +08:00
|
|
|
arr.PushBack(1);
|
|
|
|
|
arr.PushBack(2);
|
|
|
|
|
arr.PushBack(3);
|
|
|
|
|
|
|
|
|
|
// 使用 initializer_list
|
2026-03-19 00:49:08 +08:00
|
|
|
XCEngine::Containers::Array<int> arr2 = {1, 2, 3, 4, 5};
|
docs: 重构 API 文档结构并修正源码准确性
- 重组文档目录结构: 每个模块的概述页移动到模块子目录
- 重命名 index.md 为 main.md
- 修正所有模块文档中的错误:
- math: FromEuler→FromEulerAngles, TransformDirection 包含缩放, Box 是 OBB, Color::ToRGBA 格式
- containers: 新增 operator==/!= 文档, 补充 std::hash DJB 算法细节
- core: 修复 types 链接错误
- debug: LogLevelToString 返回大写, timestamp 是秒, Profiler 空实现标注, Windows API vs ANSI
- memory: 修复头文件路径, malloc vs operator new, 新增方法文档
- resources: 修复 Shader/Texture 链接错误
- threading: TaskSystem::Wait 空实现标注, ReadWriteLock 重入描述, LambdaTask 链接
- 验证: fix_links.py 确认 0 个断裂引用
2026-03-19 00:22:30 +08:00
|
|
|
|
|
|
|
|
// 迭代
|
|
|
|
|
for (auto& elem : arr) {
|
|
|
|
|
printf("%d\n", elem);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 使用 EmplaceBack
|
|
|
|
|
arr.EmplaceBack(4);
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
## 相关文档
|
|
|
|
|
|
|
|
|
|
- [HashMap](../hashmap/hashmap.md) - 哈希表容器
|
|
|
|
|
- [Memory 模块](../../memory/memory.md) - 内存分配器
|