home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 1997 May / Pcwk0597.iso / sybase / starbuck / h.z / WCSTACK.H < prev    next >
C/C++ Source or Header  |  1996-07-24  |  2KB  |  74 lines

  1. //
  2. //  wcstack.h    Defines the WATCOM Stack Container Class
  3. //
  4. //  Copyright by WATCOM International Corp. 1988-1996.  All rights reserved.
  5. //
  6. #ifndef _WCSTACK_H_INCLUDED
  7. #define _WCSTACK_H_INCLUDED
  8.  
  9. #ifndef __cplusplus
  10. #error wcstack.h is for use with C++
  11. #endif
  12.  
  13. #ifndef _WCDEFS_H_INCLUDED
  14.  #include <wcdefs.h>
  15. #endif
  16. #ifndef _WCLIST_H_INCLUDED
  17.  #include <wclist.h>
  18. #endif
  19.  
  20.  
  21.  
  22. //
  23. //  The WCStack template class defines a stack.  The template supplies
  24. //  the type of the data maintained in the stack, and the methods for
  25. //  manipulating the stack.
  26. //
  27. //  The class 'Type' should be properly defined for copy and assignment
  28. //  operations.
  29. //
  30.  
  31. template<class Type, class FType>
  32. class WCStack : private FType {
  33. public:
  34.     inline WCStack() {};
  35.     inline WCStack( void * (*user_alloc)( size_t ) 
  36.                   , void (*user_dealloc)( void *, size_t )
  37.                 ) : FType( user_alloc, user_dealloc ) {};
  38.     inline ~WCStack() {};
  39.  
  40.     inline WCbool push( const Type & data )  {
  41.         return( FType::insert( data ) );
  42.     };
  43.  
  44.     inline Type pop() {
  45.         return( FType::get() );
  46.     };
  47.  
  48.     inline Type top() const {
  49.         return( FType::find( 0 ) );
  50.     };
  51.  
  52.     inline WCbool isEmpty() const {
  53.         return( FType::isEmpty() );
  54.     };
  55.  
  56.     inline int entries() const {
  57.         return( FType::entries() );
  58.     };
  59.  
  60.     inline void clear() {
  61.         FType::clear();
  62.     };
  63.  
  64.     inline wc_state exceptions() const {
  65.         return( FType::exceptions() );
  66.     };
  67.  
  68.     inline wc_state exceptions( wc_state const set_flags ) {
  69.         return( FType::exceptions( set_flags ) );
  70.     };
  71. };
  72.  
  73. #endif
  74.