STL
This commit is contained in:
157
STL/STL-List/README.MD
Normal file
157
STL/STL-List/README.MD
Normal file
@@ -0,0 +1,157 @@
|
|||||||
|
下面是 `C++ STL list`(即 `std::list`)的**完整用法大全**,涵盖常用成员函数、迭代器、操作与用法示例,并结合功能分类。
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 🧠 基础定义
|
||||||
|
|
||||||
|
```cpp
|
||||||
|
#include <list>
|
||||||
|
std::list<int> a; // 空 list
|
||||||
|
std::list<int> b(10); // 包含10个默认值的list(int为0)
|
||||||
|
std::list<int> c(5, 42); // 包含5个42的list
|
||||||
|
std::list<int> d(b); // 拷贝构造
|
||||||
|
std::list<int> e = {1, 2, 3}; // 列表初始化(C++11)
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 🚀 成员函数分类总览
|
||||||
|
|
||||||
|
### ✅ 容器状态
|
||||||
|
|
||||||
|
| 函数名 | 说明 |
|
||||||
|
| ---------------- | --------------- |
|
||||||
|
| `empty()` | 判断是否为空 |
|
||||||
|
| `size()` | 返回元素数量 |
|
||||||
|
| `max_size()` | 返回容器可容纳的最大元素数量 |
|
||||||
|
| `clear()` | 清空所有元素 |
|
||||||
|
| `resize(n)` | 调整大小,若变大则用默认值补充 |
|
||||||
|
| `resize(n, val)` | 同上,指定补充值 |
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### ✅ 元素访问
|
||||||
|
|
||||||
|
| 函数名 | 说明 |
|
||||||
|
| --------- | ----------- |
|
||||||
|
| `front()` | 返回第一个元素的引用 |
|
||||||
|
| `back()` | 返回最后一个元素的引用 |
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### ✅ 迭代器
|
||||||
|
|
||||||
|
| 函数名 | 说明 |
|
||||||
|
| ----------- | --------------- |
|
||||||
|
| `begin()` | 指向第一个元素的迭代器 |
|
||||||
|
| `end()` | 指向最后一个元素之后的位置 |
|
||||||
|
| `rbegin()` | 反向迭代器(从后向前)开始位置 |
|
||||||
|
| `rend()` | 反向迭代器的终点 |
|
||||||
|
| `cbegin()` | const版本 |
|
||||||
|
| `cend()` | const版本 |
|
||||||
|
| `crbegin()` | const版本 |
|
||||||
|
| `crend()` | const版本 |
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### ✅ 插入/删除操作
|
||||||
|
|
||||||
|
| 函数名 | 说明 |
|
||||||
|
| ------------------------- | ---------------------- |
|
||||||
|
| `push_front(val)` | 插入元素到头部 |
|
||||||
|
| `push_back(val)` | 插入元素到尾部 |
|
||||||
|
| `pop_front()` | 删除头部元素 |
|
||||||
|
| `pop_back()` | 删除尾部元素 |
|
||||||
|
| `insert(it, val)` | 在迭代器 it 位置插入 val |
|
||||||
|
| `insert(it, n, val)` | 在 it 处插入 n 个 val |
|
||||||
|
| `insert(it, first, last)` | 插入一个区间(\[first, last)) |
|
||||||
|
| `erase(it)` | 删除 it 处元素 |
|
||||||
|
| `erase(first, last)` | 删除区间元素 |
|
||||||
|
| `remove(val)` | 删除所有等于 val 的元素 |
|
||||||
|
| `remove_if(pred)` | 删除满足谓词 pred 的元素 |
|
||||||
|
| `clear()` | 清空所有元素 |
|
||||||
|
| `emplace(it, args...)` | 原地构造插入元素 |
|
||||||
|
| `emplace_front(args...)` | 原地构造插入到头部 |
|
||||||
|
| `emplace_back(args...)` | 原地构造插入到尾部 |
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### ✅ 排序与唯一化
|
||||||
|
|
||||||
|
| 函数名 | 说明 |
|
||||||
|
| -------------------- | ---------------- |
|
||||||
|
| `sort()` | 默认从小到大排序 |
|
||||||
|
| `sort(comp)` | 自定义排序 |
|
||||||
|
| `unique()` | 去除连续重复元素 |
|
||||||
|
| `reverse()` | 反转元素顺序 |
|
||||||
|
| `merge(list2)` | 合并两个**已排序**的list |
|
||||||
|
| `merge(list2, comp)` | 使用自定义比较合并 |
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### ✅ 赋值与交换
|
||||||
|
|
||||||
|
| 函数名 | 说明 |
|
||||||
|
| --------------------- | -------------- |
|
||||||
|
| `assign(n, val)` | 赋值 n 个 val |
|
||||||
|
| `assign(first, last)` | 赋值区间元素 |
|
||||||
|
| `operator=` | 赋值运算符 |
|
||||||
|
| `swap(other)` | 与另一个 list 交换数据 |
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### ✅ splice 操作(转移元素)
|
||||||
|
|
||||||
|
| 函数名 | 说明 |
|
||||||
|
| --------------------------------- | ----------------------------------- |
|
||||||
|
| `splice(pos, list2)` | 把 list2 的所有元素移动到 pos 前 |
|
||||||
|
| `splice(pos, list2, it)` | 把 list2 中的 it 元素移动到 pos 前 |
|
||||||
|
| `splice(pos, list2, first, last)` | 把 list2 的 \[first,last) 区间移动到 pos 前 |
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 🧪 示例
|
||||||
|
|
||||||
|
```cpp
|
||||||
|
#include <iostream>
|
||||||
|
#include <list>
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
list<int> a = {1, 2, 3};
|
||||||
|
a.push_front(0); // 0 1 2 3
|
||||||
|
a.push_back(4); // 0 1 2 3 4
|
||||||
|
|
||||||
|
auto it = a.begin();
|
||||||
|
advance(it, 2);
|
||||||
|
a.insert(it, 99); // 0 1 99 2 3 4
|
||||||
|
|
||||||
|
a.remove(99); // 删除所有值为99的元素
|
||||||
|
a.reverse(); // 反转列表
|
||||||
|
|
||||||
|
for (int x : a) cout << x << " ";
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## ✅ list 特点总结
|
||||||
|
|
||||||
|
| 特性 | 是否支持 |
|
||||||
|
| ------ | -------------------------- |
|
||||||
|
| 随机访问 | ❌ 不支持(不像 `vector` 能用 `[]`) |
|
||||||
|
| 快速插入删除 | ✅ O(1) 时间在任意位置 |
|
||||||
|
| 迭代器稳定性 | ✅ 删除/插入不会使其他迭代器失效 |
|
||||||
|
| 元素连续性 | ❌ 元素不连续(不像数组或 vector) |
|
||||||
|
| 双向链表结构 | ✅ 是 |
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
如果你还想要:
|
||||||
|
|
||||||
|
* 可复制的全套模板代码
|
||||||
|
* 对每个函数的代码演示例子
|
||||||
|
* list 和 vector 的对比表
|
||||||
|
|
||||||
|
我也可以马上给你。是否继续?
|
@@ -173,3 +173,126 @@ std::string s = std::to_string(42);
|
|||||||
---
|
---
|
||||||
|
|
||||||
如需我帮你整理成一份笔记或 Markdown 文件,也可以告诉我!你也可以提你最常用的用法,我帮你列举示例。
|
如需我帮你整理成一份笔记或 Markdown 文件,也可以告诉我!你也可以提你最常用的用法,我帮你列举示例。
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
`std::string` 和 `C-style string (cstring)` 是 C++ 中处理字符串的两种主要方式,它们的 **区别与联系** 如下。
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 🧠 一句话总结:
|
||||||
|
|
||||||
|
> **`std::string` 是 C++ 的高级封装,`cstring` 是 C 语言风格的低级字符数组。**
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 🔍 一、基本概念对比
|
||||||
|
|
||||||
|
| 特性 | `C-style string (cstring)` | `std::string` |
|
||||||
|
| ---- | ---------------------------------------- | -------------------------------------------- |
|
||||||
|
| 本质 | 字符数组(如 `char[]`)以 `\0` 结尾 | 类模板 `std::basic_string<char>` |
|
||||||
|
| 所属 | C 标准库 `<cstring>` | C++ 标准库 `<string>` |
|
||||||
|
| 内存管理 | 需手动管理(如 `new`、`strcpy`) | 自动管理(RAII) |
|
||||||
|
| 长度 | 用 `strlen()` 计算 | `s.length()` |
|
||||||
|
| 操作 | 用 `strcpy()`、`strcat()`、`strcmp()` 等函数操作 | 用成员函数 `.append()`、`.substr()`、`.compare()` 等 |
|
||||||
|
| 安全性 | 易越界、易内存泄露 | 更安全 |
|
||||||
|
| 可变性 | 必须预留空间 | 动态扩展 |
|
||||||
|
| 推荐 | 适合底层接口、嵌入式等 | 推荐用于现代 C++ 开发 |
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 📦 二、cstring 提供了哪些函数(头文件 `<cstring>`)
|
||||||
|
|
||||||
|
| 函数名 | 说明 |
|
||||||
|
| ------------------------------------------- | ---------------- |
|
||||||
|
| `strlen(const char*)` | 计算字符串长度(不包括`\0`) |
|
||||||
|
| `strcpy(char*, const char*)` | 拷贝字符串 |
|
||||||
|
| `strncpy(char*, const char*, size_t)` | 安全拷贝 |
|
||||||
|
| `strcat(char*, const char*)` | 字符串拼接 |
|
||||||
|
| `strcmp(const char*, const char*)` | 比较字符串 |
|
||||||
|
| `strncmp(const char*, const char*, size_t)` | 比较前 n 个字符 |
|
||||||
|
| `strchr(const char*, char)` | 查找字符首次出现 |
|
||||||
|
| `strrchr(const char*, char)` | 查找字符最后一次出现 |
|
||||||
|
| `strstr(const char*, const char*)` | 查找子串首次出现 |
|
||||||
|
| `memcpy(void*, const void*, size_t)` | 内存拷贝 |
|
||||||
|
| `memset(void*, int, size_t)` | 内存初始化 |
|
||||||
|
| `memcmp(const void*, const void*, size_t)` | 内存比较 |
|
||||||
|
|
||||||
|
> ⚠️ 注意:这些函数不会检查数组越界,必须手动保证空间足够!
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 🎁 三、std::string 提供了哪些成员函数(头文件 `<string>`)
|
||||||
|
|
||||||
|
详见我上一个回答,但可以再快速总结:
|
||||||
|
|
||||||
|
* 构造 / 赋值:`std::string s("abc");`
|
||||||
|
* 长度:`s.length()`, `s.empty()`
|
||||||
|
* 访问:`s[i]`, `s.at(i)`
|
||||||
|
* 修改:`s += "abc"`, `s.insert()`, `s.erase()`, `s.replace()`
|
||||||
|
* 查找:`s.find("abc")`, `s.substr()`
|
||||||
|
* 比较:`s1 == s2`, `s.compare()`
|
||||||
|
* 迭代器:`begin()`, `end()`
|
||||||
|
* 与 cstring 转换:`s.c_str()`
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 🔁 四、二者之间的联系与转换
|
||||||
|
|
||||||
|
### ✅ `std::string` 转 `cstring`
|
||||||
|
|
||||||
|
```cpp
|
||||||
|
std::string s = "hello";
|
||||||
|
const char* cstr = s.c_str(); // 注意:是 const char*!
|
||||||
|
```
|
||||||
|
|
||||||
|
> ⚠️ 不可以对 `cstr` 写入内容。`c_str()` 返回的内存由 `std::string` 管理。
|
||||||
|
|
||||||
|
### ✅ `cstring` 转 `std::string`
|
||||||
|
|
||||||
|
```cpp
|
||||||
|
const char* cstr = "world";
|
||||||
|
std::string s = cstr;
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 💥 五、示例比较
|
||||||
|
|
||||||
|
```cpp
|
||||||
|
#include <iostream>
|
||||||
|
#include <cstring>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
// C-style string
|
||||||
|
char a[20] = "Hello";
|
||||||
|
strcat(a, " World"); // 注意要有足够空间
|
||||||
|
std::cout << a << std::endl;
|
||||||
|
|
||||||
|
// std::string
|
||||||
|
std::string s = "Hello";
|
||||||
|
s += " World"; // 更安全简洁
|
||||||
|
std::cout << s << std::endl;
|
||||||
|
|
||||||
|
// 转换
|
||||||
|
const char* cstr = s.c_str(); // std::string → cstring
|
||||||
|
std::string s2 = cstr; // cstring → std::string
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## ✅ 六、什么时候用哪个?
|
||||||
|
|
||||||
|
| 场景 | 推荐用法 |
|
||||||
|
| ----------------------------- | ------------------------ |
|
||||||
|
| 日常开发 | `std::string`(更安全易用) |
|
||||||
|
| 与 C 接口交互(如 `printf`, `fopen`) | 使用 `std::string.c_str()` |
|
||||||
|
| 内存受限嵌入式环境 | `cstring` |
|
||||||
|
| 学习 C 语言基础 | `cstring` |
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
如你需要,我可以给出一份“对比总结笔记表格(Markdown/LaTeX/PDF)”或演示更复杂转换例子。要吗?
|
||||||
|
223
STL/STL-Vector/README.md
Normal file
223
STL/STL-Vector/README.md
Normal file
@@ -0,0 +1,223 @@
|
|||||||
|
以下是 C++ STL 中 `std::vector` 的**全面用法大全**(涵盖常用与高级功能,包含中英文注释,适合查阅与系统学习):
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 🔷 `std::vector` 概述
|
||||||
|
|
||||||
|
`std::vector` 是一个**动态数组容器**,支持快速的随机访问与末尾插入。
|
||||||
|
|
||||||
|
```cpp
|
||||||
|
#include <vector>
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
vector<int> v; // 空 vector
|
||||||
|
vector<int> v(5); // 5 个元素,值为 0
|
||||||
|
vector<int> v(5, 10); // 5 个元素,值为 10
|
||||||
|
vector<int> v2 = {1, 2, 3}; // 列表初始化
|
||||||
|
vector<int> v3(v2); // 拷贝构造
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 🧰 常用成员函数分类一览
|
||||||
|
|
||||||
|
### ✅ 构造与初始化
|
||||||
|
|
||||||
|
```cpp
|
||||||
|
vector<int> v; // 默认构造
|
||||||
|
vector<int> v(10); // 10个默认值元素(int 默认是0)
|
||||||
|
vector<int> v(5, 3); // 5个3
|
||||||
|
vector<int> v2 = {1, 2, 3}; // 初始化列表
|
||||||
|
vector<int> v3(v2); // 拷贝构造
|
||||||
|
v.assign(4, 100); // 用4个100赋值
|
||||||
|
v.assign({1, 2, 3, 4}); // 用初始化列表赋值
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### ✅ 容量相关
|
||||||
|
|
||||||
|
```cpp
|
||||||
|
v.size(); // 元素个数
|
||||||
|
v.capacity(); // 容量(预留空间)
|
||||||
|
v.max_size(); // 最大可容纳元素数
|
||||||
|
v.empty(); // 是否为空
|
||||||
|
v.resize(10); // 调整为10个元素,默认填0
|
||||||
|
v.resize(10, -1); // 用-1填充新元素
|
||||||
|
v.shrink_to_fit(); // 缩容至实际大小
|
||||||
|
v.reserve(100); // 提前分配至少100个容量
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### ✅ 元素访问
|
||||||
|
|
||||||
|
```cpp
|
||||||
|
v[0]; // 下标访问
|
||||||
|
v.at(0); // 范围检查的访问,越界会抛异常
|
||||||
|
v.front(); // 第一个元素
|
||||||
|
v.back(); // 最后一个元素
|
||||||
|
v.data(); // 返回底层数组指针(T* 类型)
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### ✅ 修改函数
|
||||||
|
|
||||||
|
```cpp
|
||||||
|
v.push_back(5); // 末尾添加
|
||||||
|
v.pop_back(); // 移除末尾元素
|
||||||
|
v.insert(v.begin(), 3); // 在开头插入3
|
||||||
|
v.insert(v.begin() + 2, 4, 9); // 在第3个位置插入4个9
|
||||||
|
v.insert(v.end(), {7, 8, 9}); // 插入初始化列表
|
||||||
|
v.erase(v.begin()); // 删除第一个
|
||||||
|
v.erase(v.begin(), v.begin()+3);// 删除前3个
|
||||||
|
v.clear(); // 清空所有元素
|
||||||
|
v.swap(v2); // 与另一个vector交换内容
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### ✅ 迭代器相关
|
||||||
|
|
||||||
|
```cpp
|
||||||
|
vector<int>::iterator it = v.begin(); // 正向迭代器
|
||||||
|
vector<int>::iterator end = v.end();
|
||||||
|
|
||||||
|
vector<int>::reverse_iterator rit = v.rbegin(); // 反向迭代器
|
||||||
|
vector<int>::const_iterator cit = v.cbegin(); // 只读正向
|
||||||
|
vector<int>::const_reverse_iterator crit = v.crbegin(); // 只读反向
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### ✅ 排序与查找(配合算法头 `<algorithm>`)
|
||||||
|
|
||||||
|
```cpp
|
||||||
|
#include <algorithm>
|
||||||
|
|
||||||
|
sort(v.begin(), v.end()); // 升序
|
||||||
|
sort(v.rbegin(), v.rend()); // 降序
|
||||||
|
reverse(v.begin(), v.end()); // 翻转
|
||||||
|
find(v.begin(), v.end(), 3); // 查找3
|
||||||
|
count(v.begin(), v.end(), 3); // 统计3出现次数
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### ✅ 与其他容器函数通用的操作
|
||||||
|
|
||||||
|
```cpp
|
||||||
|
for (auto x : v) cout << x; // 范围for
|
||||||
|
for (auto it = v.begin(); it != v.end(); ++it)
|
||||||
|
cout << *it;
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### ✅ C++11\~20 新特性支持
|
||||||
|
|
||||||
|
```cpp
|
||||||
|
v.emplace_back(10); // 直接构造末尾元素
|
||||||
|
v.emplace(v.begin(), 20); // 在指定位置构造
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 📝 常见用途小例子
|
||||||
|
|
||||||
|
### 1. 输入一串数字
|
||||||
|
|
||||||
|
```cpp
|
||||||
|
vector<int> v;
|
||||||
|
int x;
|
||||||
|
while (cin >> x) v.push_back(x);
|
||||||
|
```
|
||||||
|
|
||||||
|
### 2. 二维 vector
|
||||||
|
|
||||||
|
```cpp
|
||||||
|
vector<vector<int>> grid(5, vector<int>(10, 0)); // 5x10 矩阵
|
||||||
|
```
|
||||||
|
|
||||||
|
### 3. 排序 + 去重
|
||||||
|
|
||||||
|
```cpp
|
||||||
|
sort(v.begin(), v.end());
|
||||||
|
v.erase(unique(v.begin(), v.end()), v.end());
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 🧠 小总结
|
||||||
|
|
||||||
|
| 分类 | 函数举例 |
|
||||||
|
| ---------- | --------------------------------------------------- |
|
||||||
|
| 初始化 | `vector<int> v(10, 5)` |
|
||||||
|
| 容量操作 | `resize`, `reserve`, `shrink_to_fit` |
|
||||||
|
| 元素访问 | `[]`, `at`, `front`, `back`, `data` |
|
||||||
|
| 增删改 | `insert`, `erase`, `push_back`, `pop_back`, `clear` |
|
||||||
|
| 迭代器 | `begin`, `end`, `rbegin`, `cbegin`, `crend` |
|
||||||
|
| 算法配合 | `sort`, `find`, `reverse`, `unique` |
|
||||||
|
| C++11/14特性 | `emplace`, `auto`, `range-for` |
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
如需我生成一份 `.cpp` 文件、或你希望看到某种使用场景的完整案例,比如:
|
||||||
|
|
||||||
|
* 大量数据插入性能优化
|
||||||
|
* 模拟二维表格
|
||||||
|
* 搜索 + 删除特定值
|
||||||
|
* 用 `vector` 实现栈/队列
|
||||||
|
|
||||||
|
我可以为你分别写出来。需要哪一种?
|
||||||
|
|
||||||
|
|
||||||
|
Member functions
|
||||||
|
(constructor) Construct vector (public member function)
|
||||||
|
(destructor) Vector destructor (public member function)
|
||||||
|
operator= Assign content (public member function)
|
||||||
|
|
||||||
|
Iterators:
|
||||||
|
begin Return iterator to beginning (public member function)
|
||||||
|
end Return iterator to end (public member function)
|
||||||
|
rbegin Return reverse iterator to reverse beginning (public member function)
|
||||||
|
rend Return reverse iterator to reverse end (public member function)
|
||||||
|
cbegin Return const_iterator to beginning (public member function)
|
||||||
|
cend Return const_iterator to end (public member function)
|
||||||
|
crbegin Return const_reverse_iterator to reverse beginning (public member function)
|
||||||
|
crend Return const_reverse_iterator to reverse end (public member function)
|
||||||
|
|
||||||
|
Capacity:
|
||||||
|
size Return size (public member function)
|
||||||
|
max_size Return maximum size (public member function)
|
||||||
|
resize Change size (public member function)
|
||||||
|
capacity Return size of allocated storage capacity (public member function)
|
||||||
|
empty Test whether vector is empty (public member function)
|
||||||
|
reserve Request a change in capacity (public member function)
|
||||||
|
shrink_to_fit Shrink to fit (public member function)
|
||||||
|
|
||||||
|
Element access:
|
||||||
|
operator[] Access element (public member function)
|
||||||
|
at Access element (public member function)
|
||||||
|
front Access first element (public member function)
|
||||||
|
back Access last element (public member function)
|
||||||
|
data Access data (public member function)
|
||||||
|
|
||||||
|
Modifiers:
|
||||||
|
assign Assign vector content (public member function)
|
||||||
|
push_back Add element at the end (public member function)
|
||||||
|
pop_back Delete last element (public member function)
|
||||||
|
insert Insert elements (public member function)
|
||||||
|
erase Erase elements (public member function)
|
||||||
|
swap Swap content (public member function)
|
||||||
|
clear Clear content (public member function)
|
||||||
|
emplace Construct and insert element (public member function)
|
||||||
|
emplace_back Construct and insert element at the end (public member function)
|
||||||
|
|
||||||
|
Allocator:
|
||||||
|
get_allocator Get allocator (public member function)
|
||||||
|
|
||||||
|
Non-member function overloads
|
||||||
|
relational operators Relational operators for vector (function template)
|
||||||
|
swap Exchange contents of vectors (function template)
|
@@ -1,48 +0,0 @@
|
|||||||
Member functions
|
|
||||||
(constructor) Construct vector (public member function)
|
|
||||||
(destructor) Vector destructor (public member function)
|
|
||||||
operator= Assign content (public member function)
|
|
||||||
|
|
||||||
Iterators:
|
|
||||||
begin Return iterator to beginning (public member function)
|
|
||||||
end Return iterator to end (public member function)
|
|
||||||
rbegin Return reverse iterator to reverse beginning (public member function)
|
|
||||||
rend Return reverse iterator to reverse end (public member function)
|
|
||||||
cbegin Return const_iterator to beginning (public member function)
|
|
||||||
cend Return const_iterator to end (public member function)
|
|
||||||
crbegin Return const_reverse_iterator to reverse beginning (public member function)
|
|
||||||
crend Return const_reverse_iterator to reverse end (public member function)
|
|
||||||
|
|
||||||
Capacity:
|
|
||||||
size Return size (public member function)
|
|
||||||
max_size Return maximum size (public member function)
|
|
||||||
resize Change size (public member function)
|
|
||||||
capacity Return size of allocated storage capacity (public member function)
|
|
||||||
empty Test whether vector is empty (public member function)
|
|
||||||
reserve Request a change in capacity (public member function)
|
|
||||||
shrink_to_fit Shrink to fit (public member function)
|
|
||||||
|
|
||||||
Element access:
|
|
||||||
operator[] Access element (public member function)
|
|
||||||
at Access element (public member function)
|
|
||||||
front Access first element (public member function)
|
|
||||||
back Access last element (public member function)
|
|
||||||
data Access data (public member function)
|
|
||||||
|
|
||||||
Modifiers:
|
|
||||||
assign Assign vector content (public member function)
|
|
||||||
push_back Add element at the end (public member function)
|
|
||||||
pop_back Delete last element (public member function)
|
|
||||||
insert Insert elements (public member function)
|
|
||||||
erase Erase elements (public member function)
|
|
||||||
swap Swap content (public member function)
|
|
||||||
clear Clear content (public member function)
|
|
||||||
emplace Construct and insert element (public member function)
|
|
||||||
emplace_back Construct and insert element at the end (public member function)
|
|
||||||
|
|
||||||
Allocator:
|
|
||||||
get_allocator Get allocator (public member function)
|
|
||||||
|
|
||||||
Non-member function overloads
|
|
||||||
relational operators Relational operators for vector (function template)
|
|
||||||
swap Exchange contents of vectors (function template)
|
|
Reference in New Issue
Block a user