home *** CD-ROM | disk | FTP | other *** search
- /*******************************************************************************
- +
- + LEDA 2.1.1 11-15-1991
- +
- +
- + stack.h
- +
- +
- + Copyright (c) 1991 by Max-Planck-Institut fuer Informatik
- + Im Stadtwald, 6600 Saarbruecken, FRG
- + All rights reserved.
- +
- *******************************************************************************/
-
-
-
-
- #ifndef STACKH
- #define STACKH
-
- #include <LEDA/basic.h>
- #include <LEDA/slist.h>
-
- //------------------------------------------------------------------------------
- // stacks
- //
- // Stefan Naeher (1988)
- //------------------------------------------------------------------------------
-
- #define stack(type) name2(type,stack)
-
- #define stackdeclare(type)\
- struct stack(type) : SLIST\
- { void copy_el(ent& x) const { Copy(*(type*)&x); }\
- void clear_el(ent& x) const { Clear(*(type*)&x); }\
- \
- stack(type)() {}\
- stack(type)(const stack(type)& S) : SLIST((SLIST&) S) {}\
- ~stack(type)() { clear(); }\
- \
- void push(type x) { SLIST::push(Ent(x)); }\
- type top() const { return type(SLIST::head()); }\
- type pop() { type x=top(); SLIST::pop(); return x; }\
- int size() const { return SLIST::length(); }\
- int empty() const { return SLIST::empty(); }\
- void clear() { SLIST::clear(); }\
- \
- stack(type)& operator=(const stack(type)& S)\
- { return (stack(type)&)SLIST::operator=((SLIST&) S); }\
- };
-
- #endif
-