Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

75 lines
2.2 KiB

  1. // stack standard header
  2. #ifndef _STACK_
  3. #define _STACK_
  4. #include <deque>
  5. #ifdef _MSC_VER
  6. #pragma pack(push,8)
  7. #endif /* _MSC_VER */
  8. _STD_BEGIN
  9. // TEMPLATE CLASS stack
  10. template<class _Ty, class _C = deque<_Ty> >
  11. class stack {
  12. public:
  13. typedef typename _C::allocator_type allocator_type;
  14. typedef typename _C::value_type value_type;
  15. typedef typename _C::size_type size_type;
  16. explicit stack(const allocator_type& _Al = allocator_type())
  17. : c(_Al) {}
  18. allocator_type get_allocator() const
  19. {return (c.get_allocator()); }
  20. bool empty() const
  21. {return (c.empty()); }
  22. size_type size() const
  23. {return (c.size()); }
  24. value_type& top()
  25. {return (c.back()); }
  26. const value_type& top() const
  27. {return (c.back()); }
  28. void push(const value_type& _X)
  29. {c.push_back(_X); }
  30. void pop()
  31. {c.pop_back(); }
  32. bool operator==(const stack<_Ty, _C>& _X) const
  33. {return (c == _X.c); }
  34. bool operator!=(const stack<_Ty, _C>& _X) const
  35. {return (!(*this == _X)); }
  36. bool operator<(const stack<_Ty, _C>& _X) const
  37. {return (c < _X.c); }
  38. bool operator>(const stack<_Ty, _C>& _X) const
  39. {return (_X < *this); }
  40. bool operator<=(const stack<_Ty, _C>& _X) const
  41. {return (!(_X < *this)); }
  42. bool operator>=(const stack<_Ty, _C>& _X) const
  43. {return (!(*this < _X)); }
  44. protected:
  45. _C c;
  46. };
  47. _STD_END
  48. #ifdef _MSC_VER
  49. #pragma pack(pop)
  50. #endif /* _MSC_VER */
  51. #endif /* _STACK_ */
  52. /*
  53. * Copyright (c) 1995 by P.J. Plauger. ALL RIGHTS RESERVED.
  54. * Consult your license regarding permissions and restrictions.
  55. */
  56. /*
  57. * This file is derived from software bearing the following
  58. * restrictions:
  59. *
  60. * Copyright (c) 1994
  61. * Hewlett-Packard Company
  62. *
  63. * Permission to use, copy, modify, distribute and sell this
  64. * software and its documentation for any purpose is hereby
  65. * granted without fee, provided that the above copyright notice
  66. * appear in all copies and that both that copyright notice and
  67. * this permission notice appear in supporting documentation.
  68. * Hewlett-Packard Company makes no representations about the
  69. * suitability of this software for any purpose. It is provided
  70. * "as is" without express or implied warranty.
  71. */