_stack.h

00001 /*
00002  *
00003  * Copyright (c) 1994
00004  * Hewlett-Packard Company
00005  *
00006  * Copyright (c) 1996,1997
00007  * Silicon Graphics Computer Systems, Inc.
00008  *
00009  * Copyright (c) 1997
00010  * Moscow Center for SPARC Technology
00011  *
00012  * Copyright (c) 1999 
00013  * Boris Fomitchev
00014  *
00015  * This material is provided "as is", with absolutely no warranty expressed
00016  * or implied. Any use is at your own risk.
00017  *
00018  * Permission to use or copy this software for any purpose is hereby granted 
00019  * without fee, provided the above notices are retained on all copies.
00020  * Permission to modify the code and to distribute modified code is granted,
00021  * provided the above notices are retained, and a notice that the code was
00022  * modified is included with the above copyright notice.
00023  *
00024  */
00025 
00026 /* NOTE: This is an internal header file, included by other STL headers.
00027  *   You should not attempt to use it directly.
00028  */
00029 
00030 #ifndef _STLP_INTERNAL_STACK_H
00031 #define _STLP_INTERNAL_STACK_H
00032 
00033 #ifndef _STLP_INTERNAL_DEQUE_H
00034 # include <stl/_deque.h>
00035 #endif
00036 
00037 _STLP_BEGIN_NAMESPACE
00038 
00039 # if !defined ( _STLP_LIMITED_DEFAULT_TEMPLATES )
00040 template <class _Tp, class _Sequence = deque<_Tp> >
00041 # elif defined ( _STLP_MINIMUM_DEFAULT_TEMPLATE_PARAMS )
00042 # define _STLP_STACK_ARGS _Tp
00043 template <class _Tp>
00044 # else
00045 template <class _Tp, class _Sequence>
00046 # endif
00047 class stack {
00048 
00049 # ifdef _STLP_STACK_ARGS 
00050   typedef deque<_Tp> _Sequence;
00051 # endif
00052 
00053 public:
00054   typedef typename _Sequence::value_type      value_type;
00055   typedef typename _Sequence::size_type       size_type;
00056   typedef          _Sequence                  container_type;
00057 
00058   typedef typename _Sequence::reference       reference;
00059   typedef typename _Sequence::const_reference const_reference;
00060 protected:
00061   _Sequence c;
00062 public:
00063   stack() : c() {}
00064   explicit stack(const _Sequence& __s) : c(__s) {}
00065 
00066   bool empty() const { return c.empty(); }
00067   size_type size() const { return c.size(); }
00068   reference top() { return c.back(); }
00069   const_reference top() const { return c.back(); }
00070   void push(const value_type& __x) { c.push_back(__x); }
00071   void pop() { c.pop_back(); }
00072   const _Sequence& _Get_c() const { return c; }
00073 };
00074 
00075 # ifndef _STLP_STACK_ARGS
00076 #  define _STLP_STACK_ARGS _Tp, _Sequence
00077 #  define _STLP_STACK_HEADER_ARGS class _Tp, class _Sequence
00078 # else
00079 #  define _STLP_STACK_HEADER_ARGS class _Tp
00080 # endif
00081 
00082 template < _STLP_STACK_HEADER_ARGS >
00083 inline bool _STLP_CALL  operator==(const stack< _STLP_STACK_ARGS >& __x, const stack< _STLP_STACK_ARGS >& __y)
00084 {
00085   return __x._Get_c() == __y._Get_c();
00086 }
00087 
00088 template < _STLP_STACK_HEADER_ARGS >
00089 inline bool _STLP_CALL  operator<(const stack< _STLP_STACK_ARGS >& __x, const stack< _STLP_STACK_ARGS >& __y)
00090 {
00091   return __x._Get_c() < __y._Get_c();
00092 }
00093 
00094 _STLP_RELOPS_OPERATORS(template < _STLP_STACK_HEADER_ARGS >, stack< _STLP_STACK_ARGS >)
00095     
00096 _STLP_END_NAMESPACE
00097 
00098 #  undef _STLP_STACK_ARGS
00099 #  undef _STLP_STACK_HEADER_ARGS
00100 
00101 #endif /* _STLP_INTERNAL_STACK_H */
00102 
00103 // Local Variables:
00104 // mode:C++
00105 // End:

Generated on Mon Jun 5 10:20:47 2006 for Intelligence.kdevelop by  doxygen 1.4.6