《STL源代码分析》---stl_stack.h读书笔记
因为只有一个堆叠端口,这也是在口腔进入口。
可以在堆栈中只能操作,你不能访问其它元件的堆叠。器。
Stack的实现是依赖其它容器的。用deque做底层数据结构。这种实现。在STL中往往不称做container容器,往往被归类为container adapter容器适配器。deque是双向开口的数据结构,功能远强大于栈,仅仅需简单分装就可以做成栈。
用其它容器做底层数据结构也但是实现栈,vector、list也支持empty、size、back、push_back、pop_back操作。我想用deque是一种折中吧!假设用vector在又一次分配空间时须要拷贝原来空间的元素。释放原来空间。假设使用list的话。每一次push_back、pop_back都涉及空间的分配和释放。
G++ 2.91.57,cygnus\cygwin-b20\include\g++\stl_stack.h 完整列表
/*** Copyright (c) 1994* Hewlett-Packard Company** 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 copyright notice appear in all copies and* that both that copyright notice and this permission notice appear* in supporting documentation. Hewlett-Packard Company makes no* representations about the suitability of this software for any* purpose. It is provided "as is" without express or implied warranty.*** Copyright (c) 1996,1997* Silicon Graphics Computer Systems, Inc.** 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 copyright notice appear in all copies and* that both that copyright notice and this permission notice appear* in supporting documentation. Silicon Graphics makes no* representations about the suitability of this software for any* purpose. It is provided "as is" without express or implied warranty.*//* NOTE: This is an internal header file, included by other STL headers.* You should not attempt to use it directly.*/#ifndef __SGI_STL_INTERNAL_STACK_H
#define __SGI_STL_INTERNAL_STACK_H__STL_BEGIN_NAMESPACE#ifndef __STL_LIMITED_DEFAULT_TEMPLATES
template <class T, class Sequence = deque<T> >
#else
template <class T, class Sequence>
#endif
class stack {//友元函数,后面会展开的friend bool operator== __STL_NULL_TMPL_ARGS (const stack&, const stack&);friend bool operator< __STL_NULL_TMPL_ARGS (const stack&, const stack&);
public:typedef typename Sequence::value_type value_type;typedef typename Sequence::size_type size_type;typedef typename Sequence::reference reference;typedef typename Sequence::const_reference const_reference;
protected:Sequence c; // 底层容器deque
public:// 下面全然利用 Sequence c 的操作,完毕 stack 的操作。bool empty() const { return c.empty(); }size_type size() const { return c.size(); }reference top() { return c.back(); }const_reference top() const { return c.back(); }void push(const value_type& x) { c.push_back(x); }void pop() { c.pop_back(); }
};template <class T, class Sequence>
bool operator==(const stack<T, Sequence>& x, const stack<T, Sequence>& y) {return x.c == y.c;
}template <class T, class Sequence>
bool operator<(const stack<T, Sequence>& x, const stack<T, Sequence>& y) {return x.c < y.c;
}__STL_END_NAMESPACE#endif /* __SGI_STL_INTERNAL_STACK_H */// Local Variables:
// mode:C++
// End:
版权声明:本文博客原创文章。博客,未经同意,不得转载。
《STL源代码分析》---stl_stack.h读书笔记相关推荐
- STL 源代码分析 算法 stl_algo.h -- includes
本文senlie原,转载请保留此地址:http://blog.csdn.net/zhengsenlie includes(应用于有序区间) ------------------------------ ...
- STL源代码分析(ch2 内存分配)jjalloc.h
1. jjalloc.h namespace JJ{ template<class T>inline T* _allocate(ptrdiff_t size,T*){ //当operato ...
- 【C语言学习趣事】_GCC源代码分析_2_assert.h
我记得在以前的一篇随笔中,我堆windows下的<assert.h>进行了分析,今天我们来看看gcc中这个文件的定义是怎样的. [1]assert宏的作用 assert宏实现断言的作用,一 ...
- 《信号完整性分析》的读书笔记和总结
对于硬件工程师,有一种说法是,硬件工程师可以分为两类,一种是已经遇到了信号完成性问题.一种是将要遇到信号完成性问题. 在进行PCB板的设计时,对于低速芯片和电路,如果芯片时钟在10MHz以下,一般来说 ...
- STL源代码分析(ch 1)概述
1. 6大组件 容器(containers):各种数据结构,如vector.list.deque.set.map,用来存放数据.从实现来看,STL容器是一种 class template. 算法(al ...
- 《STL源码剖析》读书笔记(四)
空间配置器 allocator 空间配置器 allocator 概览 精细分工 双层级配置器 相关问题 在STL中,所有的元素都是存放在容器中,容器需要配置空间来储存这些数值,因此需要用到空间配置器. ...
- 《C++STL基础及应用》读书笔记
1.五种迭代器. 输入迭代器重载 *.== .!= .前置++.后置++运算符.STL提供的主要输入迭代器是 istream_iterator . 它有两种构造函数: istream_iterator ...
- STL源代码分析(ch2 内存分配)概述
1. 使用场景 2. 配置器定义在头文件中 //负责内存空间的配置与释放; <stl_alloc.h>//文件中定义了一.二两级配置器,彼此合作,配置器名为alloc. //负责对象内容的 ...
- 《Wireshark数据包分析实战》读书笔记
1.OSI参考模型中的特殊功能: 表示层(第六层):进行用来保护数据的多种加密和解密操作. 会话层(第五层):负责以全双工或者半双工的方式来创建会话和关闭连接. 传输层(第四层):提供面向连接和无连接 ...
- 《海盗派测试分析-MFQPPDCS》——读书笔记
The best tester isn't the one who finds the most bugs or who embarrasses the most programmers. The b ...
最新文章
- TVM将深度学习模型编译为WebGL
- 简介SharePoint 2010 14 Hive文件夹
- 用例设计大全(整理)
- python饼状图颜色一样_Python饼状图的绘制实例
- matlab 读取csv_利用Pytorch进行数据加载1--CSV文件的读取和显示
- DotNetNuke出错:“Runat 属性必须具有值 Server(The Runat attribute must have the value Server Error)...
- 3.5 实例讲解Lucene索引的结构设计
- Druid 数据源连接池配置
- Linux umask限制导致php的mkdir 0777无效
- 高德地图 android 调用 amap.clear()后定位蓝点消失 如何重新显示定位
- LeetCode 70. 爬楼梯(动态规划)
- checkbox取值 php_php获取checkbox复选框的内容
- 人生没有理想,只有目标
- CSS 样式表(小结)
- vue $emit子组件传出多个参数,如何在父组件中在接收所有参数的同时添加自定义参数...
- POJ 3348 Cows
- 4用计算机显示内存不足,电脑提示内存不足或内存错误的解决方法
- Keras-Unet-语义分割
- Windows XP IIS PHP5详细配置
- CSS font-style斜体字体倾斜体样式
热门文章
- Atitit.使用引擎加脚本架构的设计 使用php,js来开发桌面程序。。
- paip.提升效率----更改数组LIST对象值for与FOREACH
- paip.提升用户体验---验证码识别与盲人
- 苏宁金融一站式API网关演进之路
- 券商交易模式下的单产品多券商方案
- 科技未来 | 计算机芯片如何拥有嗅觉?
- 【扩频通信】基于matlab CDMA直接序列扩频系统仿真【含Matlab源码 1528期】
- 【路径规划】基于matlab模糊控制机器人路径规划【含Matlab源码 1643期】
- 【图像配准】基于matlab GUI SIFT图像配准拼接【含Matlab源码 854期】
- 【图像修复】基于matlab GUI维纳滤波图像复原【含Matlab源码 851期】