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
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060 #ifndef __SGI_STL_INTERNAL_STACK_H
00061 #define __SGI_STL_INTERNAL_STACK_H
00062
00063 #include <bits/concept_check.h>
00064
00065 namespace std
00066 {
00067
00068
00069
00070 template <class _Tp,
00071 class _Sequence = deque<_Tp> >
00072 class stack;
00073
00074 template <class _Tp, class _Seq>
00075 bool operator==(const stack<_Tp,_Seq>& __x, const stack<_Tp,_Seq>& __y);
00076
00077 template <class _Tp, class _Seq>
00078 bool operator<(const stack<_Tp,_Seq>& __x, const stack<_Tp,_Seq>& __y);
00079
00080
00081 template <class _Tp, class _Sequence>
00082 class stack
00083 {
00084
00085 __glibcpp_class_requires(_Tp, _SGIAssignableConcept);
00086 __glibcpp_class_requires(_Sequence, _BackInsertionSequenceConcept);
00087 typedef typename _Sequence::value_type _Sequence_value_type;
00088 __glibcpp_class_requires2(_Tp, _Sequence_value_type, _SameTypeConcept);
00089
00090 template <class _Tp1, class _Seq1>
00091 friend bool operator== (const stack<_Tp1, _Seq1>&,
00092 const stack<_Tp1, _Seq1>&);
00093 template <class _Tp1, class _Seq1>
00094 friend bool operator< (const stack<_Tp1, _Seq1>&,
00095 const stack<_Tp1, _Seq1>&);
00096 public:
00097 typedef typename _Sequence::value_type value_type;
00098 typedef typename _Sequence::size_type size_type;
00099 typedef _Sequence container_type;
00100
00101 typedef typename _Sequence::reference reference;
00102 typedef typename _Sequence::const_reference const_reference;
00103 protected:
00104 _Sequence c;
00105 public:
00106 stack() : c() {}
00107 explicit stack(const _Sequence& __s) : c(__s) {}
00108
00109 bool empty() const { return c.empty(); }
00110 size_type size() const { return c.size(); }
00111 reference top() { return c.back(); }
00112 const_reference top() const { return c.back(); }
00113 void push(const value_type& __x) { c.push_back(__x); }
00114 void pop() { c.pop_back(); }
00115 };
00116
00117 template <class _Tp, class _Seq>
00118 bool operator==(const stack<_Tp,_Seq>& __x, const stack<_Tp,_Seq>& __y)
00119 {
00120 return __x.c == __y.c;
00121 }
00122
00123 template <class _Tp, class _Seq>
00124 bool operator<(const stack<_Tp,_Seq>& __x, const stack<_Tp,_Seq>& __y)
00125 {
00126 return __x.c < __y.c;
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 template <class _Tp, class _Seq>
00136 bool operator>(const stack<_Tp,_Seq>& __x, const stack<_Tp,_Seq>& __y)
00137 {
00138 return __y < __x;
00139 }
00140
00141 template <class _Tp, class _Seq>
00142 bool operator<=(const stack<_Tp,_Seq>& __x, const stack<_Tp,_Seq>& __y)
00143 {
00144 return !(__y < __x);
00145 }
00146
00147 template <class _Tp, class _Seq>
00148 bool operator>=(const stack<_Tp,_Seq>& __x, const stack<_Tp,_Seq>& __y)
00149 {
00150 return !(__x < __y);
00151 }
00152
00153 }
00154
00155 #endif
00156
00157
00158
00159