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

1.5 KiB

Containers 容器模块概览

命名空间: XCEngine::Containers

类型: module

描述: XCEngine 的容器模块,提供常用的数据结构实现。

概述

Containers 模块提供了图形引擎常用的数据结构,包括动态数组、字符串和哈希表。这些容器都使用自定义内存分配器接口,支持内存跟踪和优化。

模块内容

容器类

组件 文件 描述
Array Array.h 模板动态数组,支持自动扩容
String String.h 动态字符串类
HashMap HashMap.h 模板哈希表

设计特点

  1. 自定义内存分配器支持 - 所有容器都支持通过 IAllocator 接口分配内存
  2. 迭代器支持 - Array 和 HashMap 都提供 STL 风格的迭代器
  3. 移动语义 - 完整支持 C++11 移动语义
  4. 异常安全 - 内存分配失败时提供良好的错误处理

使用示例

#include <XCEngine/Containers/Array.h>
#include <XCEngine/Containers/String.h>
#include <XCEngine/Containers/HashMap.h>

// 使用 Array
XCEngine::Containers::Array<int> arr;
arr.PushBack(1);
arr.PushBack(2);
arr.PushBack(3);

// 使用 String
XCEngine::Containers::String str;
str = "Hello, ";
str += "World!";

// 使用 HashMap
XCEngine::Containers::HashMap<XCEngine::Containers::String, int> map;
map.Insert("key1", 100);
map.Insert("key2", 200);
int* value = map.Find("key1");

相关文档