stl
文章平均质量分 69
zzyoucan
做技术切勿浮躁时刻对自己定位准确切记切记
展开
-
关于容器的各种操作
对于容器有增,删,查,改这几种操作,对于不同的容器有不同的操作(1)顺序容器:1.插入元素:对于c.push_back(t)和c.insert(p,t)顺序容器都可以操作,c.push_front(t)只适用于list和deque 容器,vector不允许在首部插入元素,原创 2011-09-15 23:45:41 · 850 阅读 · 0 评论 -
关于c++中的适配器
c++中的适配器有三种:容器适配器,迭代器适配器,函数适配器下面一一介绍1.容器适配器:具体的有stack,queue,priority_queue,默认的情况下,stack和queue基于deque而实现的,priority_queue在vector上实现的,可以根据第二个原创 2011-09-16 14:26:42 · 4895 阅读 · 0 评论 -
仿函数
二元判断式:Binary Predicates的典型用途是比较两个参数的特定属性,例如为了依照自己的原则对元素进行排序,必须提供简单的predicate形式提供这项原则,如果元素不支持operator#include #include #include #include using namespace std;class Person{public: Person(stri原创 2013-08-18 22:32:38 · 701 阅读 · 0 评论 -
lower_bound, upper_bound,equal_range
template FwdIt lower_bound(FwdIt first, FwdIt last, const T& val);template FwdIt lower_bound(FwdIt first, FwdIt last, const T& val, Pred pr);template FwdIt upper_bound(FwdIt first, FwdIt原创 2013-08-10 12:53:13 · 724 阅读 · 0 评论 -
map与multimap
map与multimap其实与set与multiset差不错,set与multiset是一种特殊的map与multimap。其再命名空间的定义如下:namespace std{ template <class key, class t, class compare = less, class allocator = allocator>> class map ;原创 2013-08-11 22:03:22 · 4883 阅读 · 0 评论 -
pair(对组)
struct pair可以将两个值视为一个单元,c++标准程序库内多处使用了这个struct,尤其在map与multimap中就是使用pair来管理其键值/实值(key/value)的成对元素,任何函数返回两个值也需要pair,pair定义于中name std{ template struct pair{ typedef T1 first_type ; typedef T2 sec原创 2013-08-10 23:02:31 · 1325 阅读 · 0 评论 -
set与multiset
set和Multiset会根据特定的排序规则自动将元素排序,multiset允许元素重复,set不允许元素重复,二者在std中定义如下:namespace std{ template <class T, class Compare = less, class Allocator = allocator> class set ; template <clas原创 2013-08-11 14:56:06 · 934 阅读 · 0 评论