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

  1. //
  2. //  wcqueue.h    Defines the WATCOM Queue Container Class
  3. //
  4. //  Copyright by WATCOM International Corp. 1988-1996.  All rights reserved.
  5. //
  6. #ifndef _WCQUEUE_H_INCLUDED
  7. #define _WCQUEUE_H_INCLUDED
  8.  
  9. #ifndef __cplusplus
  10. #error wcqueue.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 WCQueue template class defines a queue.  The template supplies
  24. //  the type of the data maintained in the queue, and the methods for
  25. //  manipulating the queue.
  26. //
  27. //  The insert operation does an append.  This is because an item
  28. //  inserted into a queue is actually the last item removed.
  29. //
  30. //  The class 'Type' should be properly defined for copy and assignment
  31. //  operations.
  32. //
  33.  
  34. template<class Type, class FType>
  35. class WCQueue : private FType {
  36. public:
  37.     inline WCQueue() {};
  38.     inline WCQueue( void * (*user_alloc)( size_t )
  39.                   , void (*user_dealloc)( void *, size_t )
  40.                 ) : FType( user_alloc, user_dealloc ) {};
  41.     inline ~WCQueue() {};
  42.  
  43.     inline WCbool insert( const Type & data )  {
  44.         return( FType::append( data ) );
  45.     };
  46.  
  47.     inline WCbool isEmpty() const {
  48.         return( FType::isEmpty() );
  49.     };
  50.  
  51.     inline int entries() const {
  52.         return( FType::entries() );
  53.     };
  54.  
  55.     inline Type get() {
  56.         return( FType::get() );
  57.     };
  58.  
  59.     inline Type first() const {
  60.         return( FType::find( 0 ) );
  61.     };
  62.  
  63.     inline Type last() const {
  64.         return( FType::findLast() );
  65.     };
  66.  
  67.     inline void clear() {
  68.         FType::clear();
  69.     };
  70.  
  71.     inline wc_state exceptions() const {
  72.         return( FType::exceptions() );
  73.     };
  74.  
  75.     inline wc_state exceptions( wc_state const set_flags ) {
  76.         return( FType::exceptions( set_flags ) );
  77.     };
  78. };
  79.  
  80. #endif
  81.