This commit is contained in:
estomm
2021-03-06 11:41:44 +08:00
parent 1be8d28fc4
commit 63c2e49897
3 changed files with 49 additions and 3 deletions

View File

@@ -9,8 +9,8 @@
## 0 简介
### 概念
适配器 (adaptor) 是标准库巾的一个通用概念。容器、法代糕和1函数〈歪吕 都有适配器。 本质上, 一个适配器是一种机制, 能使某种事物的行为看起来像另外一种事 物一样。。一个容器适配器接受一种己有的容器类型, 使其行为看起来像一利1不同的类型。
* 适配器 (adaptor) 是标准库巾的一个通用概念。容器、类和函数都有适配器。 本质上, 一个适配器是一种机制, 能使某种事物的行为看起来像另外一种事物一样。。一个容器适配器接受一种己有的容器类型, 使其行为看起来像一利1不同的类型。
* 添加额外操作,实现某种特殊的数据结构。
### 容器适配器的操作

View File

@@ -10,7 +10,7 @@
### 说明
* 容器的迭代器算法不依赖于容器。但算法依赖于元素类型的操作。
* 容器的**迭代器**使得算法不依赖于容器。但算法依赖于元素类型的操作。
* 标准库仅仅提供了100多个算法
### 分类
@@ -18,6 +18,28 @@
* 只读算法。不改变元素的值
* 更易算法。该表容器的元素
### 示例
* 只读算法
accumulate()
* 判断算法
equal()
* 写容器算法
fill()
* 拷贝算法
copy()
* 重排算法
sort()
unique()
## 2

24
C++/标准库/4.cpp Normal file
View File

@@ -0,0 +1,24 @@
#include<iostream>
#include<vector>
#include<deque>
#include<algorithm>
#include<numeric>
using namespace std;
//unique sort
void unique_sort(vectro<int> &word){
sort(words.begin(),words.end());
auto end_unique = unique(words.begin(),words.end());
words.erase(end_unique,words.end());
}
int main(){
vector<int> n{4,2,5,2,5,6,7};
for(int m :n){
cout<<m<<" "<<end;
}
cout<<endl;
}