home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / vc98 / crt / src / stack < prev    next >
Text File  |  1998-06-16  |  2KB  |  81 lines

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