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
00071
template <
class _Tp,
00072
class _Sequence = deque<_Tp> >
00073
class stack;
00074
00075
template <
class _Tp,
class _Seq>
00076
bool operator==(
const stack<_Tp,_Seq>& __x,
const stack<_Tp,_Seq>& __y);
00077
00078
template <
class _Tp,
class _Seq>
00079
bool operator<(const stack<_Tp,_Seq>& __x,
const stack<_Tp,_Seq>& __y);
00080
00081
00082
template <
class _Tp,
class _Sequence>
00083
class stack
00084 {
00085
00086 __glibcpp_class_requires(_Tp, _SGIAssignableConcept)
00087 __glibcpp_class_requires(_Sequence, _BackInsertionSequenceConcept)
00088 typedef typename _Sequence::value_type _Sequence_value_type;
00089 __glibcpp_class_requires2(_Tp, _Sequence_value_type, _SameTypeConcept);
00090
00091 template <class _Tp1, class _Seq1>
00092 friend
bool operator== (const stack<_Tp1, _Seq1>&,
00093 const stack<_Tp1, _Seq1>&);
00094 template <class _Tp1, class _Seq1>
00095 friend
bool operator< (const stack<_Tp1, _Seq1>&,
00096 const stack<_Tp1, _Seq1>&);
00097 public:
00098 typedef typename _Sequence::value_type value_type;
00099 typedef typename _Sequence::size_type size_type;
00100 typedef _Sequence container_type;
00101
00102 typedef typename _Sequence::reference reference;
00103 typedef typename _Sequence::const_reference const_reference;
00104 protected:
00105 _Sequence c;
00106 public:
00107 stack() : c() {}
00108
explicit stack(
const _Sequence& __s) : c(__s) {}
00109
00110
bool empty()
const {
return c.empty(); }
00111 size_type size()
const {
return c.size(); }
00112 reference top() {
return c.back(); }
00113 const_reference top()
const {
return c.back(); }
00114
void push(
const value_type& __x) { c.push_back(__x); }
00115
void pop() { c.pop_back(); }
00116 };
00117
00118
template <
class _Tp,
class _Seq>
00119
bool operator==(
const stack<_Tp,_Seq>& __x,
const stack<_Tp,_Seq>& __y)
00120 {
00121
return __x.c == __y.c;
00122 }
00123
00124
template <
class _Tp,
class _Seq>
00125
bool operator<(const stack<_Tp,_Seq>& __x,
const stack<_Tp,_Seq>& __y)
00126 {
00127
return __x.c < __y.c;
00128 }
00129
00130
template <
class _Tp,
class _Seq>
00131
bool operator!=(
const stack<_Tp,_Seq>& __x,
const stack<_Tp,_Seq>& __y)
00132 {
00133
return !(__x == __y);
00134 }
00135
00136
template <
class _Tp,
class _Seq>
00137
bool operator>(
const stack<_Tp,_Seq>& __x,
const stack<_Tp,_Seq>& __y)
00138 {
00139
return __y < __x;
00140 }
00141
00142
template <
class _Tp,
class _Seq>
00143
bool operator<=(const stack<_Tp,_Seq>& __x,
const stack<_Tp,_Seq>& __y)
00144 {
00145
return !(__y < __x);
00146 }
00147
00148
template <
class _Tp,
class _Seq>
00149
bool operator>=(
const stack<_Tp,_Seq>& __x,
const stack<_Tp,_Seq>& __y)
00150 {
00151
return !(__x < __y);
00152 }
00153
00154 }
00155
00156
#endif
00157
00158
00159
00160