
STL 源码剖析
文章平均质量分 76
本专栏用于记录学习STL源码,会上传所有亲自测试过的源码。从内存池技术开始,再到迭代器,然后是容器,然后是算法。感谢侯捷先生的《STL源码剖析》
!!!
pandening
我很笨,但我很勤劳!
展开
-
STL配置器(四)----内存池技术
关于内存池,我相信大家都比较感兴趣,实现的版本也很多,但无论怎么实现,我觉得很重要的一点是:不能让管理内存池的成本太大!这是关键。比如,你管理100M的内存需要花50M的空间才能搞定,那我觉得不如直接用malloc和free来得实在,除了管理内存消耗外,还要注意效率,如果效率太低那也没什么意义。 本质上,内存池技术的出现是为了减少fragment碎片问题,用malloc和free来操作内存容易造原创 2016-04-08 22:48:22 · 2627 阅读 · 0 评论 -
STL迭代器(一)
迭代器学习(一)《STL 源码剖析》中,第三章叫“迭代器概念与traits编程技法”。总共33页,我艰难的读了一遍,愚蠢的我还是被所谓“traits技法”惊呆了!说白了,想要真正明白迭代器,就必须了解traits编程技术。 但不忙,在看什么是traits之前,先看看什么叫“迭代器”:迭代器是一种设计模式,他要求提供一种方法,使之能够一次访问某个聚合物内部的元素,而又无需暴露该聚合物内部的表达方式。原创 2016-04-10 13:59:32 · 638 阅读 · 0 评论 -
STL vector
/* * * Copyright (c) 2016 hujian. * Permission to use, copy, modify, distribute and sell this software * and its documentation for any purpose is hereby granted without fee, * provided that the above原创 2016-04-17 16:42:04 · 430 阅读 · 0 评论 -
STL list
/* * * Copyright (c) 2016 hujian. * Permission to use, copy, modify, distribute and sell this software * and its documentation for any purpose is hereby granted without fee, * provided that the above c原创 2016-04-18 21:47:11 · 429 阅读 · 0 评论 -
STL 源码剖析 deque实现源码
#ifndef _HJSTL_DEQUE_H_ #define _HJSTL_DEQUE_H_ /* * Author:hujian * Time:2016/4/28 * discription:this file is about deque structure. * */ #include "hjstl_alloc.h" #include "hjstl_construct.h原创 2016-04-28 14:31:10 · 2403 阅读 · 0 评论 -
STL 源码剖析 stack
#ifndef _HJSTL_STACK_H_ #define _HJSTL_STACK_H_ /* * Author:hujian * Time:2016/4/30 * discription:this file is about stack structure. * NOTICE:using deque as the low-level structure of stack. * you ca原创 2016-04-30 20:53:50 · 449 阅读 · 0 评论 -
STL 源码剖析 queue
#ifndef _HJSTL_QUEUE_H_ #define _HJSTL_QUEUE_H_ /* * Author:hujian * Time:2016/4/30 * discription:this file is about queue structure. * NOTICE:using deque as the low-level structure of queue. * you ca原创 2016-04-30 20:54:45 · 428 阅读 · 0 评论