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
00061 #ifndef __GLIBCPP_INTERNAL_STACK_H
00062 #define __GLIBCPP_INTERNAL_STACK_H
00063
00064 #include <bits/concept_check.h>
00065
00066 namespace std
00067 {
00068
00069
00070 template <typename _Tp, typename _Sequence = deque<_Tp> >
00071 class stack;
00072
00073 template <typename _Tp, typename _Seq>
00074 inline bool operator==(const stack<_Tp,_Seq>& __x,
00075 const stack<_Tp,_Seq>& __y);
00076
00077 template <typename _Tp, typename _Seq>
00078 inline bool operator<(const stack<_Tp,_Seq>& __x, const stack<_Tp,_Seq>& __y);
00079
00080
00105 template <typename _Tp, typename _Sequence>
00106 class stack
00107 {
00108
00109 typedef typename _Sequence::value_type _Sequence_value_type;
00110 __glibcpp_class_requires(_Tp, _SGIAssignableConcept)
00111 __glibcpp_class_requires(_Sequence, _BackInsertionSequenceConcept)
00112 __glibcpp_class_requires2(_Tp, _Sequence_value_type, _SameTypeConcept)
00113
00114 template <typename _Tp1, typename _Seq1>
00115 friend bool operator== (const stack<_Tp1, _Seq1>&,
00116 const stack<_Tp1, _Seq1>&);
00117 template <typename _Tp1, typename _Seq1>
00118 friend bool operator< (const stack<_Tp1, _Seq1>&,
00119 const stack<_Tp1, _Seq1>&);
00120
00121 public:
00122 typedef typename _Sequence::value_type value_type;
00123 typedef typename _Sequence::reference reference;
00124 typedef typename _Sequence::const_reference const_reference;
00125 typedef typename _Sequence::size_type size_type;
00126 typedef _Sequence container_type;
00127
00128 protected:
00129
00130 _Sequence c;
00131
00132 public:
00133
00137 explicit
00138 stack(const _Sequence& __c = _Sequence())
00139 : c(__c) {}
00140
00144 bool
00145 empty() const { return c.empty(); }
00146
00148 size_type
00149 size() const { return c.size(); }
00150
00155 reference
00156 top() { return c.back(); }
00157
00162 const_reference
00163 top() const { return c.back(); }
00164
00174 void
00175 push(const value_type& __x) { c.push_back(__x); }
00176
00187 void
00188 pop() { c.pop_back(); }
00189 };
00190
00191
00203 template <typename _Tp, typename _Seq>
00204 inline bool
00205 operator==(const stack<_Tp,_Seq>& __x, const stack<_Tp,_Seq>& __y)
00206 { return __x.c == __y.c; }
00207
00220 template <typename _Tp, typename _Seq>
00221 inline bool
00222 operator<(const stack<_Tp,_Seq>& __x, const stack<_Tp,_Seq>& __y)
00223 { return __x.c < __y.c; }
00224
00226 template <typename _Tp, typename _Seq>
00227 inline bool
00228 operator!=(const stack<_Tp,_Seq>& __x, const stack<_Tp,_Seq>& __y)
00229 { return !(__x == __y); }
00230
00232 template <typename _Tp, typename _Seq>
00233 inline bool
00234 operator>(const stack<_Tp,_Seq>& __x, const stack<_Tp,_Seq>& __y)
00235 { return __y < __x; }
00236
00238 template <typename _Tp, typename _Seq>
00239 inline bool
00240 operator<=(const stack<_Tp,_Seq>& __x, const stack<_Tp,_Seq>& __y)
00241 { return !(__y < __x); }
00242
00244 template <typename _Tp, typename _Seq>
00245 inline bool
00246 operator>=(const stack<_Tp,_Seq>& __x, const stack<_Tp,_Seq>& __y)
00247 { return !(__x < __y); }
00248 }
00249
00250 #endif