From 63c2e498976f29945ddc7820d91c0f893f513f37 Mon Sep 17 00:00:00 2001 From: estomm Date: Sat, 6 Mar 2021 11:41:44 +0800 Subject: [PATCH] faf --- C++/标准库/2.3 容器适配器.md | 4 ++-- C++/标准库/4 算法.md | 24 +++++++++++++++++++++++- C++/标准库/4.cpp | 24 ++++++++++++++++++++++++ 3 files changed, 49 insertions(+), 3 deletions(-) create mode 100644 C++/标准库/4.cpp diff --git a/C++/标准库/2.3 容器适配器.md b/C++/标准库/2.3 容器适配器.md index b9e6eac1..8310be72 100644 --- a/C++/标准库/2.3 容器适配器.md +++ b/C++/标准库/2.3 容器适配器.md @@ -9,8 +9,8 @@ ## 0 简介 ### 概念 -适配器 (adaptor) 是标准库巾的一个通用概念。容器、法代糕和1函数〈歪吕 都有适配器。 本质上, 一个适配器是一种机制, 能使某种事物的行为看起来像另外一种事 物一样。。一个容器适配器接受一种己有的容器类型, 使其行为看起来像一利1不同的类型。 - +* 适配器 (adaptor) 是标准库巾的一个通用概念。容器、类和函数都有适配器。 本质上, 一个适配器是一种机制, 能使某种事物的行为看起来像另外一种事物一样。。一个容器适配器接受一种己有的容器类型, 使其行为看起来像一利1不同的类型。 +* 添加额外操作,实现某种特殊的数据结构。 ### 容器适配器的操作 diff --git a/C++/标准库/4 算法.md b/C++/标准库/4 算法.md index 67b94a6d..f3c7a13f 100644 --- a/C++/标准库/4 算法.md +++ b/C++/标准库/4 算法.md @@ -10,7 +10,7 @@ ### 说明 -* 容器的迭代器零算法不依赖于容器。但算法依赖于元素类型的操作。 +* 容器的**迭代器**使得算法不依赖于容器。但算法依赖于元素类型的操作。 * 标准库仅仅提供了100多个算法 ### 分类 @@ -18,6 +18,28 @@ * 只读算法。不改变元素的值 * 更易算法。该表容器的元素 +### 示例 +* 只读算法 +accumulate() + +* 判断算法 + +equal() + +* 写容器算法 + +fill() + +* 拷贝算法 + +copy() + +* 重排算法 + +sort() +unique() + + ## 2 diff --git a/C++/标准库/4.cpp b/C++/标准库/4.cpp new file mode 100644 index 00000000..92732339 --- /dev/null +++ b/C++/标准库/4.cpp @@ -0,0 +1,24 @@ +#include +#include +#include +#include +#include +using namespace std; + +//unique sort +void unique_sort(vectro &word){ + sort(words.begin(),words.end()); + auto end_unique = unique(words.begin(),words.end()); + words.erase(end_unique,words.end()); +} + + + +int main(){ + vector n{4,2,5,2,5,6,7}; + + for(int m :n){ + cout<