由于之前在debug模式下发现stl的sort简直慢到不能忍,所以自己写了一个sgi的sort,后来发现在release模式下,vs自带的sort快的不行,就研究了下。
这里有些和sgi-stl相通的东西就简略带过了,详细内容可以看我之前的stl源码的笔记:
sgi-sort_link
首先来看下大概的过程: 1.没有调用到一定深度时,就进行划分并进行递归调用。
2.如果超过了一定深度...
分类:
其他好文 时间:
2015-04-24 09:04:53
阅读次数:
177
五类迭代器如下:
1、输入迭代器:只读,一次传递
为输入迭代器预定义实现只有istream_iterator和istreambuf_iterator,用于从一个输入流istream中读取。一个输入迭代器仅能对它所选择的每个元素进行一次解析,它们只能向前移动。一个专门的构造函数定义了超越末尾的值。总是,输入迭代器可以对读操作的结果进行解析(对每个值仅解析一次),然后向前移动。
2...
分类:
其他好文 时间:
2015-04-23 19:59:54
阅读次数:
135
STL的设计非常巧妙,组件间互取短长,形成了一个世界,这是这个世界里的组件:
1. containers(容器):所谓容器,是指存放数据的地方,将数据以一定的方法组织存放。根据不同的组织方式,可以把容器分为顺序容器,如vector、deque、list,关联容器,如set、map。Container是一种class template。
2. algorithm(算法):各种常用不常用的算法如s...
分类:
其他好文 时间:
2015-04-16 21:55:30
阅读次数:
220
STL 源码分析 # stl_iterator_base && stl_iterator #
这里能很清楚的看到各个基础类型的继承关系
template struct input_iterator {
typedef input_iterator_tag iterator_category;
typedef _Tp...
分类:
其他好文 时间:
2015-04-13 14:40:01
阅读次数:
138
STL 源码分析 # stl_pair #
pair是一种很简单也很常用的关联容器(associative container).
/***********************************************
Programmer : EOF
Date : 2015.04.10
File : pair.cpp
E-mail : jaso...
分类:
其他好文 时间:
2015-04-10 15:32:52
阅读次数:
160
STL 源码分析 # stl_number #
/***********************************************************
Programmer : EOF
e-mail : jasonleaster@gmail.com
Date : 2015.04.04
File : 6number.cpp
********************...
分类:
其他好文 时间:
2015-04-09 19:58:47
阅读次数:
153
//---------------------------15/04/05----------------------------
/*
空间配置器概述:
1:new操作包含两个阶段操作
1>调用::operator new配置内存(底层使用malloc来申请内存)。
2>调用函数的构造函数,构造对象内容。
...
分类:
其他好文 时间:
2015-04-06 11:29:31
阅读次数:
151
//---------------------------15/04/03----------------------------
/*
配接器概述:
1:adapter是一种设计模式:将一个class的接口转换为另一个class的接口,使得原本因接口不兼容而
不能合作的classes可以一起工作。
2:改变仿函数接口的,称...
分类:
其他好文 时间:
2015-04-04 09:21:44
阅读次数:
113
STL 源码分析 之 rotate()函数分析
rotate()函数究竟能干嘛?
http://www.cplusplus.com/reference/algorithm/rotate/?kw=rotate
上面只是大致的截图, 源码在下面给出:
// rotate and rotate_copy, and their auxiliary ...
分类:
其他好文 时间:
2015-04-02 18:55:01
阅读次数:
198
//---------------------------15/04/01----------------------------
//inplace_merge(要求有序)
templateclass BidirectionalIterator>
inline void inplace_merge(BidirectionalIterator first,
...
分类:
编程语言 时间:
2015-04-01 17:49:53
阅读次数:
131