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
00031 #ifndef __SGI_STL_INTERNAL_STACK_H
00032 #define __SGI_STL_INTERNAL_STACK_H
00033
00034 #include <sequence_concepts.h>
00035
00036 __STL_BEGIN_NAMESPACE
00037
00038
00039
00040 template <class _Tp,
00041 class _Sequence __STL_DEPENDENT_DEFAULT_TMPL(deque<_Tp>) >
00042 class stack;
00043
00044 template <class _Tp, class _Seq>
00045 bool operator==(const stack<_Tp,_Seq>& __x, const stack<_Tp,_Seq>& __y);
00046
00047 template <class _Tp, class _Seq>
00048 bool operator<(const stack<_Tp,_Seq>& __x, const stack<_Tp,_Seq>& __y);
00049
00050
00051 template <class _Tp, class _Sequence>
00052 class stack {
00053
00054
00055
00056 __STL_CLASS_REQUIRES(_Tp, _Assignable);
00057 __STL_CLASS_REQUIRES(_Sequence, _BackInsertionSequence);
00058 typedef typename _Sequence::value_type _Sequence_value_type;
00059 __STL_CLASS_REQUIRES_SAME_TYPE(_Tp, _Sequence_value_type);
00060
00061
00062 #ifdef __STL_MEMBER_TEMPLATES
00063 template <class _Tp1, class _Seq1>
00064 friend bool operator== (const stack<_Tp1, _Seq1>&,
00065 const stack<_Tp1, _Seq1>&);
00066 template <class _Tp1, class _Seq1>
00067 friend bool operator< (const stack<_Tp1, _Seq1>&,
00068 const stack<_Tp1, _Seq1>&);
00069 #else
00070 friend bool __STD_QUALIFIER
00071 operator== __STL_NULL_TMPL_ARGS (const stack&, const stack&);
00072 friend bool __STD_QUALIFIER
00073 operator< __STL_NULL_TMPL_ARGS (const stack&, const stack&);
00074 #endif
00075
00076 public:
00077 typedef typename _Sequence::value_type value_type;
00078 typedef typename _Sequence::size_type size_type;
00079 typedef _Sequence container_type;
00080
00081 typedef typename _Sequence::reference reference;
00082 typedef typename _Sequence::const_reference const_reference;
00083 protected:
00084 _Sequence c;
00085 public:
00086 stack() : c() {}
00087 explicit stack(const _Sequence& __s) : c(__s) {}
00088
00089 bool empty() const { return c.empty(); }
00090 size_type size() const { return c.size(); }
00091 reference top() { return c.back(); }
00092 const_reference top() const { return c.back(); }
00093 void push(const value_type& __x) { c.push_back(__x); }
00094 void pop() { c.pop_back(); }
00095 };
00096
00097 template <class _Tp, class _Seq>
00098 bool operator==(const stack<_Tp,_Seq>& __x, const stack<_Tp,_Seq>& __y)
00099 {
00100 return __x.c == __y.c;
00101 }
00102
00103 template <class _Tp, class _Seq>
00104 bool operator<(const stack<_Tp,_Seq>& __x, const stack<_Tp,_Seq>& __y)
00105 {
00106 return __x.c < __y.c;
00107 }
00108
00109 #ifdef __STL_FUNCTION_TMPL_PARTIAL_ORDER
00110
00111 template <class _Tp, class _Seq>
00112 bool operator!=(const stack<_Tp,_Seq>& __x, const stack<_Tp,_Seq>& __y)
00113 {
00114 return !(__x == __y);
00115 }
00116
00117 template <class _Tp, class _Seq>
00118 bool operator>(const stack<_Tp,_Seq>& __x, const stack<_Tp,_Seq>& __y)
00119 {
00120 return __y < __x;
00121 }
00122
00123 template <class _Tp, class _Seq>
00124 bool operator<=(const stack<_Tp,_Seq>& __x, const stack<_Tp,_Seq>& __y)
00125 {
00126 return !(__y < __x);
00127 }
00128
00129 template <class _Tp, class _Seq>
00130 bool operator>=(const stack<_Tp,_Seq>& __x, const stack<_Tp,_Seq>& __y)
00131 {
00132 return !(__x < __y);
00133 }
00134
00135 #endif
00136
00137 __STL_END_NAMESPACE
00138
00139 #endif
00140
00141
00142
00143