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
This commit is contained in:
51
docs/api/containers/string/operator-subscript.md
Normal file
51
docs/api/containers/string/operator-subscript.md
Normal file
@@ -0,0 +1,51 @@
|
||||
# String::operator[]
|
||||
|
||||
```cpp
|
||||
char& operator[](SizeType index);
|
||||
const char& operator[](SizeType index) const;
|
||||
```
|
||||
|
||||
通过索引访问字符串中的字符。
|
||||
|
||||
**参数:**
|
||||
- `index` - 要访问的字符位置(从 0 开始)
|
||||
|
||||
**返回:** 位置 `index` 处字符的引用(可写或只读)
|
||||
|
||||
**复杂度:** O(1)
|
||||
|
||||
**注意:** 不进行边界检查。调用者需确保 `index < Length()`。
|
||||
|
||||
**示例:**
|
||||
```cpp
|
||||
#include "XCEngine/Containers/String.h"
|
||||
#include <iostream>
|
||||
|
||||
int main() {
|
||||
XCEngine::Containers::String s("Hello");
|
||||
|
||||
// 只读访问
|
||||
for (XCEngine::Containers::String::SizeType i = 0; i < s.Length(); ++i) {
|
||||
std::cout << s[i];
|
||||
}
|
||||
std::cout << std::endl; // 输出: Hello
|
||||
|
||||
// 可写访问
|
||||
s[0] = 'J';
|
||||
s[1] = 'a';
|
||||
s[4] = '!';
|
||||
std::cout << s.CStr() << std::endl; // 输出: Jallo!
|
||||
|
||||
// const 版本
|
||||
const XCEngine::Containers::String& cs = s;
|
||||
char first = cs[0];
|
||||
std::cout << "First char: " << first << std::endl; // 输出: First char: J
|
||||
|
||||
return 0;
|
||||
}
|
||||
```
|
||||
|
||||
## 相关文档
|
||||
|
||||
- [String 总览](string.md) - 返回类总览
|
||||
- [Length](size.md) - 获取长度
|
||||
Reference in New Issue
Block a user