00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030 #ifndef _STLP_INTERNAL_STACK_H
00031 #define _STLP_INTERNAL_STACK_H
00032
00033 #ifndef _STLP_INTERNAL_DEQUE_H
00034 # include <stl/_deque.h>
00035 #endif
00036
00037 _STLP_BEGIN_NAMESPACE
00038
00039 # if !defined ( _STLP_LIMITED_DEFAULT_TEMPLATES )
00040 template <class _Tp, class _Sequence = deque<_Tp> >
00041 # elif defined ( _STLP_MINIMUM_DEFAULT_TEMPLATE_PARAMS )
00042 # define _STLP_STACK_ARGS _Tp
00043 template <class _Tp>
00044 # else
00045 template <class _Tp, class _Sequence>
00046 # endif
00047 class stack {
00048
00049 # ifdef _STLP_STACK_ARGS
00050 typedef deque<_Tp> _Sequence;
00051 # endif
00052
00053 public:
00054 typedef typename _Sequence::value_type value_type;
00055 typedef typename _Sequence::size_type size_type;
00056 typedef _Sequence container_type;
00057
00058 typedef typename _Sequence::reference reference;
00059 typedef typename _Sequence::const_reference const_reference;
00060 protected:
00061 _Sequence c;
00062 public:
00063 stack() : c() {}
00064 explicit stack(const _Sequence& __s) : c(__s) {}
00065
00066 bool empty() const { return c.empty(); }
00067 size_type size() const { return c.size(); }
00068 reference top() { return c.back(); }
00069 const_reference top() const { return c.back(); }
00070 void push(const value_type& __x) { c.push_back(__x); }
00071 void pop() { c.pop_back(); }
00072 const _Sequence& _Get_c() const { return c; }
00073 };
00074
00075 # ifndef _STLP_STACK_ARGS
00076 # define _STLP_STACK_ARGS _Tp, _Sequence
00077 # define _STLP_STACK_HEADER_ARGS class _Tp, class _Sequence
00078 # else
00079 # define _STLP_STACK_HEADER_ARGS class _Tp
00080 # endif
00081
00082 template < _STLP_STACK_HEADER_ARGS >
00083 inline bool _STLP_CALL operator==(const stack< _STLP_STACK_ARGS >& __x, const stack< _STLP_STACK_ARGS >& __y)
00084 {
00085 return __x._Get_c() == __y._Get_c();
00086 }
00087
00088 template < _STLP_STACK_HEADER_ARGS >
00089 inline bool _STLP_CALL operator<(const stack< _STLP_STACK_ARGS >& __x, const stack< _STLP_STACK_ARGS >& __y)
00090 {
00091 return __x._Get_c() < __y._Get_c();
00092 }
00093
00094 _STLP_RELOPS_OPERATORS(template < _STLP_STACK_HEADER_ARGS >, stack< _STLP_STACK_ARGS >)
00095
00096 _STLP_END_NAMESPACE
00097
00098 # undef _STLP_STACK_ARGS
00099 # undef _STLP_STACK_HEADER_ARGS
00100
00101 #endif
00102
00103
00104
00105