| 1 | // This may look like C code, but it is really -*- C++ -*-
|
|---|
| 2 | /*
|
|---|
| 3 | Copyright (C) 1988 Free Software Foundation
|
|---|
| 4 | written by Doug Lea ([email protected])
|
|---|
| 5 | based on code by Marc Shapiro ([email protected])
|
|---|
| 6 |
|
|---|
| 7 | This file is part of the GNU C++ Library. This library is free
|
|---|
| 8 | software; you can redistribute it and/or modify it under the terms of
|
|---|
| 9 | the GNU Library General Public License as published by the Free
|
|---|
| 10 | Software Foundation; either version 2 of the License, or (at your
|
|---|
| 11 | option) any later version. This library is distributed in the hope
|
|---|
| 12 | that it will be useful, but WITHOUT ANY WARRANTY; without even the
|
|---|
| 13 | implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
|---|
| 14 | PURPOSE. See the GNU Library General Public License for more details.
|
|---|
| 15 | You should have received a copy of the GNU Library General Public
|
|---|
| 16 | License along with this library; if not, write to the Free Software
|
|---|
| 17 | Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|---|
| 18 | */
|
|---|
| 19 |
|
|---|
| 20 |
|
|---|
| 21 | #ifndef _<T>XPStack_h
|
|---|
| 22 | #ifdef __GNUG__
|
|---|
| 23 | #pragma interface
|
|---|
| 24 | #endif
|
|---|
| 25 | #define _<T>XPStack_h
|
|---|
| 26 |
|
|---|
| 27 | #include "<T>.XPlex.h"
|
|---|
| 28 | #include "<T>.Stack.h"
|
|---|
| 29 |
|
|---|
| 30 | class <T>XPStack : public <T>Stack
|
|---|
| 31 | {
|
|---|
| 32 | <T>XPlex p;
|
|---|
| 33 |
|
|---|
| 34 | public:
|
|---|
| 35 | <T>XPStack(int chunksize = DEFAULT_INITIAL_CAPACITY);
|
|---|
| 36 | <T>XPStack(const <T>XPStack& s);
|
|---|
| 37 | inline ~<T>XPStack();
|
|---|
| 38 |
|
|---|
| 39 | void operator = (const <T>XPStack&);
|
|---|
| 40 |
|
|---|
| 41 | inline void push(<T&> item);
|
|---|
| 42 | inline <T> pop();
|
|---|
| 43 | inline <T>& top();
|
|---|
| 44 | inline void del_top();
|
|---|
| 45 |
|
|---|
| 46 | inline int empty();
|
|---|
| 47 | inline int full();
|
|---|
| 48 | inline int length();
|
|---|
| 49 |
|
|---|
| 50 | inline void clear();
|
|---|
| 51 |
|
|---|
| 52 | inline int OK();
|
|---|
| 53 |
|
|---|
| 54 | };
|
|---|
| 55 |
|
|---|
| 56 |
|
|---|
| 57 | inline <T>XPStack::<T>XPStack(int chunksize)
|
|---|
| 58 | : p(chunksize) {}
|
|---|
| 59 | inline <T>XPStack::<T>XPStack(const <T>XPStack& s) : p(s.p) {}
|
|---|
| 60 |
|
|---|
| 61 | inline <T>XPStack::~<T>XPStack() {}
|
|---|
| 62 |
|
|---|
| 63 | inline void <T>XPStack::push(<T&>item)
|
|---|
| 64 | {
|
|---|
| 65 | p.add_high(item);
|
|---|
| 66 | }
|
|---|
| 67 |
|
|---|
| 68 | inline <T> <T>XPStack::pop()
|
|---|
| 69 | {
|
|---|
| 70 | <T> res = p.high_element();
|
|---|
| 71 | p.del_high();
|
|---|
| 72 | return res;
|
|---|
| 73 | }
|
|---|
| 74 |
|
|---|
| 75 | inline <T>& <T>XPStack::top()
|
|---|
| 76 | {
|
|---|
| 77 | return p.high_element();
|
|---|
| 78 | }
|
|---|
| 79 |
|
|---|
| 80 | inline void <T>XPStack::del_top()
|
|---|
| 81 | {
|
|---|
| 82 | p.del_high();
|
|---|
| 83 | }
|
|---|
| 84 |
|
|---|
| 85 | inline void <T>XPStack::operator =(const <T>XPStack& s)
|
|---|
| 86 | {
|
|---|
| 87 | p.operator = (s.p);
|
|---|
| 88 | }
|
|---|
| 89 |
|
|---|
| 90 | inline int <T>XPStack::empty()
|
|---|
| 91 | {
|
|---|
| 92 | return p.empty();
|
|---|
| 93 | }
|
|---|
| 94 |
|
|---|
| 95 | inline int <T>XPStack::full()
|
|---|
| 96 | {
|
|---|
| 97 | return p.full();
|
|---|
| 98 | }
|
|---|
| 99 |
|
|---|
| 100 | inline int <T>XPStack::length()
|
|---|
| 101 | {
|
|---|
| 102 | return p.length();
|
|---|
| 103 | }
|
|---|
| 104 |
|
|---|
| 105 | inline int <T>XPStack::OK()
|
|---|
| 106 | {
|
|---|
| 107 | return p.OK();
|
|---|
| 108 | }
|
|---|
| 109 |
|
|---|
| 110 | inline void <T>XPStack::clear()
|
|---|
| 111 | {
|
|---|
| 112 | p.clear();
|
|---|
| 113 | }
|
|---|
| 114 |
|
|---|
| 115 | #endif
|
|---|