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

39 lines
812 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.
# Array::Front() / Back()
```cpp
T& Front();
const T& Front() const;
T& Back();
const T& Back() const;
```
获取数组首尾元素的引用。
**Front()** 返回第一个元素(`index == 0`)的引用。
**Back()** 返回最后一个元素(`index == Size() - 1`)的引用。
**前置条件:** 数组必须非空,否则行为未定义。
**返回:** 首/尾元素的引用
**复杂度:** O(1)
**线程安全:** ❌ 访问期间不可并发修改
**示例:**
```cpp
Containers::Array<int> arr = {10, 20, 30};
int& first = arr.Front(); // first == 10
int& last = arr.Back(); // last == 30
arr.Front() = 5; // arr 现在是 {5, 20, 30}
arr.Back() = 100; // arr 现在是 {5, 20, 100}
```
## 相关文档
- [Array 总览](array.md) - 返回类总览