home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD2.mdf / c / library / dos / diverses / leda / incl / queue.h < prev    next >
Encoding:
C/C++ Source or Header  |  1991-11-15  |  1.5 KB  |  57 lines

  1. /*******************************************************************************
  2. +
  3. +  LEDA  2.1.1                                                 11-15-1991
  4. +
  5. +
  6. +  queue.h
  7. +
  8. +
  9. +  Copyright (c) 1991  by  Max-Planck-Institut fuer Informatik
  10. +  Im Stadtwald, 6600 Saarbruecken, FRG     
  11. +  All rights reserved.
  12. *******************************************************************************/
  13.  
  14.  
  15.  
  16.  
  17. #ifndef QUEUEH
  18. #define QUEUEH
  19.  
  20. //------------------------------------------------------------------------------
  21. // queue                                                                
  22. //                                                                      
  23. // Stefan Naeher
  24. //------------------------------------------------------------------------------
  25.  
  26. #include <LEDA/basic.h>
  27.  
  28. #ifndef SLISTH
  29. #include <LEDA/slist.h>
  30. #endif
  31.  
  32.  
  33. #define queue(type) name2(type,queue)
  34.  
  35. #define queuedeclare(type)\
  36. struct queue(type) : SLIST\
  37. { void copy_el(ent& x)  const { Copy(*(type*)&x); }\
  38.   void clear_el(ent& x) const { Clear(*(type*)&x); }\
  39. \
  40.   queue(type)() {}\
  41.   queue(type)(const queue(type)& Q) : SLIST((SLIST&) Q) {}\
  42.  ~queue(type)() { clear(); }\
  43. \
  44.   void append(type x) { SLIST::append(Ent(x)); }\
  45.   type top()   const  { return type(SLIST::head()); }\
  46.   type pop()          { type x=top(); SLIST::pop(); return x; }\
  47.   int  size()  const  { return SLIST::length(); }\
  48.   int  empty() const  { return SLIST::empty(); }\
  49.   void clear()        { SLIST::clear(); }\
  50. \
  51.   queue(type)& operator=(const queue(type)& Q)\
  52.   { return (queue(type)&)SLIST::operator=((SLIST&) Q); }\
  53. };
  54.  
  55. #endif
  56.