STL 源码剖析 stack
来源:互联网 发布:mysql 现实数据库 编辑:程序博客网 时间:2024/06/05 00:09
#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 can use list replace deque to do the same work.* */#define _HJSTL_STACK_PUBLIC public#define _HJSTL_STACK_PRIVZTE private#define _HJSTL_STACK_PROTECTED protected#include "hjstl_deque.h"template<class Type,class Sequence=_HJSTL_deque<Type>/*use deque to create stack*/>class _HJSTL_stack{friend bool operator==(const _HJSTL_stack&, const _HJSTL_stack&);friend bool operator<(const _HJSTL_stack&, const _HJSTL_stack&);_HJSTL_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;_HJSTL_STACK_PROTECTED://we can say,this is the stack instance.Sequence c;_HJSTL_STACK_PUBLIC://useful functionbool empty(){ 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&v){ c.push_back(v); }void pop(){ c.pop_back(); }};//end of hjstl stack//implement the friend functiontemplate<class Type,class Sequence>bool operator==(const _HJSTL_stack<Type, Sequence>&x, const _HJSTL_stack<Type, Sequence>& y){return x.c == y.c;}//implement the friend functiontemplate<class Type, class Sequence>bool operator<(const _HJSTL_stack<Type, Sequence>&x, const _HJSTL_stack<Type, Sequence>& y){return x.c<y.c;}#endif //end of hjstl stack
0 0
- STL 源码剖析 stack
- STL 之 stack 源码剖析
- STL源码剖析---stack,queue
- STL源码剖析----stack、heap、queue
- STL源码剖析——stack
- STL源码剖析之stack,queue容器【2013.11.25】
- STL源码剖析——容器配接器之stack
- STL源码剖析 - 第4章 序列式容器 - stack
- stl源码剖析 详细学习笔记stack queue
- 《stl源码剖析》剖析
- C# Stack源码剖析
- [STL]源码解析:stack
- STL源码:stack
- STL源码剖析(1)
- STL源码剖析(2)
- STL源码剖析(3)
- STL源码剖析(4)
- STL源码剖析(5)
- springmvc实现图片的上传
- 基于Jetsontk1和OpenCV下的人脸检测
- java项目——防止羊毛党“薅羊毛”
- 文章标题
- HDU 5253 连接的管道 (bfs + 优先队列)
- STL 源码剖析 stack
- shiro---你的所见所得由我决定
- 关于Hello Hell项目的经验总结
- STL 源码剖析 queue
- Java:垃圾回收机制
- APP开发之原型图设计
- 1001 Problem A
- 剑指Offer--031-连续子数组的最大和
- C经典 指针与指针所指向的值的区别