home *** CD-ROM | disk | FTP | other *** search
- /*******************************************************************************
- +
- + LEDA 2.1.1 11-15-1991
- +
- +
- + queue.h
- +
- +
- + Copyright (c) 1991 by Max-Planck-Institut fuer Informatik
- + Im Stadtwald, 6600 Saarbruecken, FRG
- + All rights reserved.
- +
- *******************************************************************************/
-
-
-
-
- #ifndef QUEUEH
- #define QUEUEH
-
- //------------------------------------------------------------------------------
- // queue
- //
- // Stefan Naeher
- //------------------------------------------------------------------------------
-
- #include <LEDA/basic.h>
-
- #ifndef SLISTH
- #include <LEDA/slist.h>
- #endif
-
-
- #define queue(type) name2(type,queue)
-
- #define queuedeclare(type)\
- struct queue(type) : SLIST\
- { void copy_el(ent& x) const { Copy(*(type*)&x); }\
- void clear_el(ent& x) const { Clear(*(type*)&x); }\
- \
- queue(type)() {}\
- queue(type)(const queue(type)& Q) : SLIST((SLIST&) Q) {}\
- ~queue(type)() { clear(); }\
- \
- void append(type x) { SLIST::append(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(); }\
- \
- queue(type)& operator=(const queue(type)& Q)\
- { return (queue(type)&)SLIST::operator=((SLIST&) Q); }\
- };
-
- #endif
-