Co-Authored-By: ouuan <y___o___u@126.com>
- **映射** ( `map` ) 由 {键,值} 对组成的集合,以某种比较键大小关系的谓词进行排列。
- **多重映射** ( `multimap` ) 由 {键,值} 对组成的多重集合,亦即允许键有相等情况的映射。
-???+note 什么是谓词( [ **Predicate** ](https://en.wikipedia.org/wiki/Predicate_(mathematical_logic)) )?
+???+note "什么是谓词 ( [ **Predicate** ](https://en.wikipedia.org/wiki/Predicate_(mathematical_logic)) )?"
谓词就是返回值为真或者假的函数。STL 容器中经常会使用到谓词,用于模板参数。
### 无序(关联式)容器
```cpp
vector<int> data(10);
-for (int i = 0; i < 10; i++) cout << data[i] << endl; // 使用下标访问元素
+for (int i = 0; i < data.size(); i++) cout << data[i] << endl; // 使用下标访问元素
for (vector<int>::iterator iter = data.begin(); iter != data.end(); iter++)
cout << *iter << endl; // 使用迭代器访问元素
| `+` (双目) | 加法 |
| `-` (双目) | 减法 |
-??? note“单目与双目运算符”
+??? note "单目与双目运算符"
单目运算符(又称一元运算符)指被操作对象只有一个的运算符,而双目运算符(又称二元运算符)的被操作对象有两个。例如 `1+2` 中加号就是双目运算符,它有 `1` 和 `2` 两个被操作数。此外 C++ 中还有唯一的一个三目运算符 `?:` 。
算术运算符中有两个单目运算符(正、负)以及五个双目运算符(乘法、除法、取模、加法、减法),其中单目运算符的优先级最高。