williamr@4
|
1 |
/*
|
williamr@4
|
2 |
*
|
williamr@4
|
3 |
* Copyright (c) 1994
|
williamr@4
|
4 |
* Hewlett-Packard Company
|
williamr@4
|
5 |
*
|
williamr@4
|
6 |
* Copyright (c) 1996,1997
|
williamr@4
|
7 |
* Silicon Graphics Computer Systems, Inc.
|
williamr@4
|
8 |
*
|
williamr@4
|
9 |
* Copyright (c) 1997
|
williamr@4
|
10 |
* Moscow Center for SPARC Technology
|
williamr@4
|
11 |
*
|
williamr@4
|
12 |
* Copyright (c) 1999
|
williamr@4
|
13 |
* Boris Fomitchev
|
williamr@4
|
14 |
*
|
williamr@4
|
15 |
* This material is provided "as is", with absolutely no warranty expressed
|
williamr@4
|
16 |
* or implied. Any use is at your own risk.
|
williamr@4
|
17 |
*
|
williamr@4
|
18 |
* Permission to use or copy this software for any purpose is hereby granted
|
williamr@4
|
19 |
* without fee, provided the above notices are retained on all copies.
|
williamr@4
|
20 |
* Permission to modify the code and to distribute modified code is granted,
|
williamr@4
|
21 |
* provided the above notices are retained, and a notice that the code was
|
williamr@4
|
22 |
* modified is included with the above copyright notice.
|
williamr@4
|
23 |
*
|
williamr@4
|
24 |
*/
|
williamr@4
|
25 |
|
williamr@4
|
26 |
/* NOTE: This is an internal header file, included by other STL headers.
|
williamr@4
|
27 |
* You should not attempt to use it directly.
|
williamr@4
|
28 |
*/
|
williamr@4
|
29 |
|
williamr@4
|
30 |
#ifndef _STLP_INTERNAL_STACK_H
|
williamr@4
|
31 |
#define _STLP_INTERNAL_STACK_H
|
williamr@4
|
32 |
|
williamr@4
|
33 |
#ifndef _STLP_INTERNAL_DEQUE_H
|
williamr@4
|
34 |
# include <stl/_deque.h>
|
williamr@4
|
35 |
#endif
|
williamr@4
|
36 |
|
williamr@4
|
37 |
_STLP_BEGIN_NAMESPACE
|
williamr@4
|
38 |
|
williamr@4
|
39 |
#if !defined ( _STLP_LIMITED_DEFAULT_TEMPLATES )
|
williamr@4
|
40 |
template <class _Tp, class _Sequence = deque<_Tp> >
|
williamr@4
|
41 |
#elif defined ( _STLP_MINIMUM_DEFAULT_TEMPLATE_PARAMS )
|
williamr@4
|
42 |
# define _STLP_STACK_ARGS _Tp
|
williamr@4
|
43 |
template <class _Tp>
|
williamr@4
|
44 |
#else
|
williamr@4
|
45 |
template <class _Tp, class _Sequence>
|
williamr@4
|
46 |
#endif
|
williamr@4
|
47 |
class stack
|
williamr@4
|
48 |
#if defined (_STLP_USE_PARTIAL_SPEC_WORKAROUND)
|
williamr@4
|
49 |
# if defined (_STLP_STACK_ARGS)
|
williamr@4
|
50 |
: public __stlport_class<stack<_Tp> >
|
williamr@4
|
51 |
# else
|
williamr@4
|
52 |
: public __stlport_class<stack<_Tp, _Sequence> >
|
williamr@4
|
53 |
# endif
|
williamr@4
|
54 |
#endif
|
williamr@4
|
55 |
{
|
williamr@4
|
56 |
#ifdef _STLP_STACK_ARGS
|
williamr@4
|
57 |
typedef deque<_Tp> _Sequence;
|
williamr@4
|
58 |
typedef stack<_Tp> _Self;
|
williamr@4
|
59 |
#else
|
williamr@4
|
60 |
typedef stack<_Tp, _Sequence> _Self;
|
williamr@4
|
61 |
#endif
|
williamr@4
|
62 |
|
williamr@4
|
63 |
public:
|
williamr@4
|
64 |
typedef typename _Sequence::value_type value_type;
|
williamr@4
|
65 |
typedef typename _Sequence::size_type size_type;
|
williamr@4
|
66 |
typedef _Sequence container_type;
|
williamr@4
|
67 |
|
williamr@4
|
68 |
typedef typename _Sequence::reference reference;
|
williamr@4
|
69 |
typedef typename _Sequence::const_reference const_reference;
|
williamr@4
|
70 |
protected:
|
williamr@4
|
71 |
//c is a Standard name (23.2.3.3), do no make it STLport naming convention compliant.
|
williamr@4
|
72 |
_Sequence c;
|
williamr@4
|
73 |
public:
|
williamr@4
|
74 |
stack() : c() {}
|
williamr@4
|
75 |
explicit stack(const _Sequence& __s) : c(__s) {}
|
williamr@4
|
76 |
|
williamr@4
|
77 |
stack(__move_source<_Self> src)
|
williamr@4
|
78 |
: c(_STLP_PRIV _AsMoveSource(src.get().c)) {}
|
williamr@4
|
79 |
|
williamr@4
|
80 |
bool empty() const { return c.empty(); }
|
williamr@4
|
81 |
size_type size() const { return c.size(); }
|
williamr@4
|
82 |
reference top() { return c.back(); }
|
williamr@4
|
83 |
const_reference top() const { return c.back(); }
|
williamr@4
|
84 |
void push(const value_type& __x) { c.push_back(__x); }
|
williamr@4
|
85 |
void pop() { c.pop_back(); }
|
williamr@4
|
86 |
const _Sequence& _Get_s() const { return c; }
|
williamr@4
|
87 |
};
|
williamr@4
|
88 |
|
williamr@4
|
89 |
#ifndef _STLP_STACK_ARGS
|
williamr@4
|
90 |
# define _STLP_STACK_ARGS _Tp, _Sequence
|
williamr@4
|
91 |
# define _STLP_STACK_HEADER_ARGS class _Tp, class _Sequence
|
williamr@4
|
92 |
#else
|
williamr@4
|
93 |
# define _STLP_STACK_HEADER_ARGS class _Tp
|
williamr@4
|
94 |
#endif
|
williamr@4
|
95 |
|
williamr@4
|
96 |
template < _STLP_STACK_HEADER_ARGS >
|
williamr@4
|
97 |
inline bool _STLP_CALL operator==(const stack< _STLP_STACK_ARGS >& __x,
|
williamr@4
|
98 |
const stack< _STLP_STACK_ARGS >& __y)
|
williamr@4
|
99 |
{ return __x._Get_s() == __y._Get_s(); }
|
williamr@4
|
100 |
|
williamr@4
|
101 |
template < _STLP_STACK_HEADER_ARGS >
|
williamr@4
|
102 |
inline bool _STLP_CALL operator<(const stack< _STLP_STACK_ARGS >& __x,
|
williamr@4
|
103 |
const stack< _STLP_STACK_ARGS >& __y)
|
williamr@4
|
104 |
{ return __x._Get_s() < __y._Get_s(); }
|
williamr@4
|
105 |
|
williamr@4
|
106 |
_STLP_RELOPS_OPERATORS(template < _STLP_STACK_HEADER_ARGS >, stack< _STLP_STACK_ARGS >)
|
williamr@4
|
107 |
|
williamr@4
|
108 |
#undef _STLP_STACK_ARGS
|
williamr@4
|
109 |
#undef _STLP_STACK_HEADER_ARGS
|
williamr@4
|
110 |
|
williamr@4
|
111 |
#if defined (_STLP_CLASS_PARTIAL_SPECIALIZATION)
|
williamr@4
|
112 |
template <class _Tp, class _Sequence>
|
williamr@4
|
113 |
struct __move_traits<stack<_Tp, _Sequence> > :
|
williamr@4
|
114 |
_STLP_PRIV __move_traits_aux<_Sequence>
|
williamr@4
|
115 |
{};
|
williamr@4
|
116 |
#endif
|
williamr@4
|
117 |
|
williamr@4
|
118 |
_STLP_END_NAMESPACE
|
williamr@4
|
119 |
|
williamr@4
|
120 |
#endif /* _STLP_INTERNAL_STACK_H */
|
williamr@4
|
121 |
|
williamr@4
|
122 |
// Local Variables:
|
williamr@4
|
123 |
// mode:C++
|
williamr@4
|
124 |
// End:
|