1 // stack standard header
2 #pragma once
3 #ifndef _STACK_
4 #define _STACK_
5 #ifndef RC_INVOKED
6 #include <deque>
7
8 #ifdef _MSC_VER
9  #pragma pack(push,_CRT_PACKING)
10  #pragma warning(push,3)
11 #endif  /* _MSC_VER */
12 _STD_BEGIN
13
14         // TEMPLATE CLASS stack
15 template<class _Ty,
16     class _Container = deque<_Ty> >
17     class stack
18     {    // LIFO queue implemented with a container
19 public:
20     typedef _Container container_type;
21     typedef typename _Container::value_type value_type;
22     typedef typename _Container::size_type size_type;
23     typedef typename _Container::reference reference;
24     typedef typename _Container::const_reference const_reference;
25
26     stack()
27         : c()
28         {    // construct with empty container
29         }
30
31     explicit stack(const _Container& _Cont)
32         : c(_Cont)
33         {    // construct by copying specified container
34         }
35
36     bool empty() const
37         {    // test if stack is empty
38         return (c.empty());
39         }
40
41     size_type size() const
42         {    // test length of stack
43         return (c.size());
44         }
45
46     reference top()
47         {    // return last element of mutable stack
48         return (c.back());
49         }
50
51     const_reference top() const
52         {    // return last element of nonmutable stack
53         return (c.back());
54         }
55
56     void push(const value_type& _Val)
57         {    // insert element at end
58         c.push_back(_Val);
59         }
60
61     void pop()
Lines 62 ... 71 are skipped.
72     _Container c;    // the underlying container
73     };
74
75         // stack TEMPLATE FUNCTIONS
76 template<class _Ty,
77     class _Container> inline
78     bool operator==(const stack<_Ty, _Container>& _Left,
79         const stack<_Ty, _Container>& _Right)
80     {    // test for stack equality
81     return (_Left._Get_container() == _Right._Get_container());
82     }
83
84 template<class _Ty,
85     class _Container> inline
86     bool operator!=(const stack<_Ty, _Container>& _Left,
87         const stack<_Ty, _Container>& _Right)
88     {    // test for stack inequality
89     return (!(_Left == _Right));
90     }
91
92 template<class _Ty,
93     class _Container> inline
94     bool operator<(const stack<_Ty, _Container>& _Left,
95         const stack<_Ty, _Container>& _Right)
96     {    // test if _Left < _Right for stacks
97     return (_Left._Get_container() < _Right._Get_container());
98     }
99
100 template<class _Ty,
101     class _Container> inline
102     bool operator>(const stack<_Ty, _Container>& _Left,
103         const stack<_Ty, _Container>& _Right)
104     {    // test if _Left > _Right for stacks
105     return (_Right < _Left);
106     }
107
108 template<class _Ty,
109     class _Container> inline
110     bool operator<=(const stack<_Ty, _Container>& _Left,
111         const stack<_Ty, _Container>& _Right)
112     {    // test if _Left <= _Right for stacks
113     return (!(_Right < _Left));
114     }
115
116 template<class _Ty,
117     class _Container> inline
118     bool operator>=(const stack<_Ty, _Container>& _Left,
119         const stack<_Ty, _Container>& _Right)
120     {    // test if _Left >= _Right for stacks
121     return (!(_Left < _Right));
122     }
123 _STD_END
124
125 #ifdef _MSC_VER
126  #pragma warning(pop)
127  #pragma pack(pop)
128 #endif  /* _MSC_VER */
129
130 #endif /* RC_INVOKED */
131 #endif /* _STACK_ */
132
133 /*
134  * Copyright (c) 1992-2006 by P.J. Plauger.  ALL RIGHTS RESERVED.
135  * Consult your license regarding permissions and restrictions.
136  */
137
138 /*
139  * This file is derived from software bearing the following
140  * restrictions:
141  *
142  * Copyright (c) 1994
143  * Hewlett-Packard Company
144  *
145  * Permission to use, copy, modify, distribute and sell this
146  * software and its documentation for any purpose is hereby
147  * granted without fee, provided that the above copyright notice
148  * appear in all copies and that both that copyright notice and
149  * this permission notice appear in supporting documentation.
150  * Hewlett-Packard Company makes no representations about the
151  * suitability of this software for any purpose. It is provided
152  * "as is" without express or implied warranty.
153  V5.02:0009 */
154