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

  1. /*******************************************************************************
  2. +
  3. +  LEDA  2.1.1                                                 11-15-1991
  4. +
  5. +
  6. +  stack.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 STACKH
  18. #define STACKH
  19.  
  20. #include <LEDA/basic.h>
  21. #include  <LEDA/slist.h>
  22.  
  23. //------------------------------------------------------------------------------
  24. // stacks                                                                
  25. //                                                                      
  26. // Stefan Naeher (1988)                                                
  27. //------------------------------------------------------------------------------
  28.  
  29. #define stack(type) name2(type,stack)
  30.  
  31. #define stackdeclare(type)\
  32. struct stack(type) : SLIST\
  33. { void copy_el(ent& x)  const { Copy(*(type*)&x); }\
  34.   void clear_el(ent& x) const { Clear(*(type*)&x); }\
  35. \
  36.   stack(type)() {}\
  37.   stack(type)(const stack(type)& S) : SLIST((SLIST&) S) {}\
  38.  ~stack(type)() { clear(); }\
  39. \
  40.   void push(type x)  { SLIST::push(Ent(x)); }\
  41.   type top()   const { return type(SLIST::head()); }\
  42.   type pop()         { type x=top(); SLIST::pop(); return x; }\
  43.   int  size()  const { return SLIST::length(); }\
  44.   int  empty() const { return SLIST::empty(); }\
  45.   void clear()       { SLIST::clear(); }\
  46. \
  47.   stack(type)& operator=(const stack(type)& S)\
  48.   { return (stack(type)&)SLIST::operator=((SLIST&) S); }\
  49. };
  50.  
  51. #endif
  52.