
C++STL
文章平均质量分 53
KingOfMyHeart
会好起来的.
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
STL源码剖析---deque
我们先来看一下deque的底层结构长什么样子: start 指向头的迭代器(_M_start) finish 指向尾部的下一个位置的迭代器(_M_finish) cur 指向当前元素 first 指向当前buffer内的第一个元素 last 指向单钱buffer的最后一个元素 node 指向当前buffer的指针 map_size node的个数 由图结合源代码可知...原创 2018-08-07 13:49:08 · 228 阅读 · 0 评论 -
容器适配器复习
实际上,容器适配器在工作中使用的不是特别多,所以对这些东西的个别细节难免有些遗忘,今天这里回顾一下。 什么是适配器 适配器类底层组合了已经有的容器对象,对外开发一些接口,这些接口实际上是对容器接口的封装,或者直接调用容器对象的方法。 容器适配器没有自己的数据结构,没有自己的迭代器,实现全部依赖于底层的组合的容器。 比如, template <class T,class Container = deque<T>> class stack { public: void pop() {原创 2022-05-30 20:55:01 · 190 阅读 · 1 评论 -
c++STL中的绑定器bind1st和bind2nd,以及自己实现一个bind1st
一元函数对象:对象重载了operator(),并且只含有一个形参变量; 二元函数对象:对象重载了operator(),含有两个形参变量; 如: template<class _Ty = void> struct greater : public binary_function<_Ty, _Ty, bool> { // functor for operat...原创 2020-04-16 21:35:53 · 671 阅读 · 0 评论 -
c++typename
#include <iostream> #include <vector> #include <algorithm> //所有泛型算法 #include <functional>//所有函数对象 #include <ctime> template <typename container> void print_contain...原创 2020-04-16 20:58:16 · 260 阅读 · 0 评论 -
C++STL六大部件概述以及容器结构概述
容器(Containers) 分配器(Allocators) 算法(Algorithms) 迭代器(Iterators) 适配器(Adapters) 仿函数(Functors) 一、六大部件之间存在的关系: 1.容器:存放我们要操作的数据,可以是数字、对象等; 2.分配器:容器需要占用内存,容器占用的内存由分配器分配; 3.算法:被独立出来的模板函数,用来操作容器,包块常见的排序算法、查找算...原创 2019-05-20 16:44:10 · 1154 阅读 · 0 评论 -
C++STL之数组Array(C++11)
一、数组的简单使用以及用时测试: #include<iostream> #include<array> #include<cstdlib>//qsort bsearch NULL #include<ctime> using namespace std; const int SIZE = 100000;//数组的长度 int main() { ...原创 2019-05-21 07:31:49 · 3736 阅读 · 2 评论 -
C++STL之vector动态数组
一、vector的简单使用以及耗时测试: #include<iostream> #include<vector> #include<cstdlib>//qsort bsearch NULL #include<ctime> using namespace std; const int SIZE = 100000; int main() { vecto...原创 2019-05-21 09:36:26 · 907 阅读 · 0 评论 -
C++STL之双向链表list
一、list的基本使用以及耗时测试: #include<list> #include<cstdlib>//qsort bsearch NULL #include<ctime> using namespace std; const int SIZE = 100000; int main() { list<int>l;//定义一个链表容器对象l,第二...原创 2019-06-07 10:09:15 · 563 阅读 · 0 评论 -
C++STL之双端队列deque
一说到队列,大家多数人和我一样,第一反应是FIFO原则。 那么双端队列就是一个方向(头或者尾)就可以进也可以出,听起来我们的双端队列是一种具有队列和栈的性质的数据结构。是一种线性的数据结构,相比list增加 [] 运算符重载。 大概长这个样子: 实际上,在内存中这不是他的真实模样,比这个要复杂的多。 一、双端队列deque的基本使用: #include <iostream> #inc...原创 2019-06-07 11:42:20 · 2709 阅读 · 0 评论