1
|
1 /* |
829
|
2 |
2847
|
3 Copyright (C) 1996, 1997 John W. Eaton |
829
|
4 |
|
5 This file is part of Octave. |
|
6 |
|
7 Octave is free software; you can redistribute it and/or modify it |
|
8 under the terms of the GNU General Public License as published by the |
|
9 Free Software Foundation; either version 2, or (at your option) any |
|
10 later version. |
|
11 |
|
12 Octave is distributed in the hope that it will be useful, but WITHOUT |
|
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
15 for more details. |
|
16 |
|
17 You should have received a copy of the GNU General Public License |
|
18 along with Octave; see the file COPYING. If not, write to the Free |
1315
|
19 Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
829
|
20 |
|
21 */ |
|
22 |
|
23 /* |
|
24 |
|
25 The classes in this file are derived from the old `genclass' version |
|
26 of SLStack from libg++, originally: |
|
27 |
|
28 Copyright (C) 1988 Free Software Foundation |
1
|
29 written by Doug Lea (dl@rocky.oswego.edu) |
|
30 |
829
|
31 and distributed under the terms of the GNU Library General Public |
|
32 License as published by the Free Software Foundation. |
|
33 |
1
|
34 */ |
|
35 |
240
|
36 #if !defined (_SLStack_h) |
|
37 #define _SLStack_h 1 |
1
|
38 |
2580
|
39 #if defined (__GNUG__) |
|
40 #pragma interface |
|
41 #endif |
|
42 |
355
|
43 #include "SLList.h" |
|
44 #include "Stack.h" |
|
45 |
1
|
46 template <class T> |
452
|
47 class |
|
48 SLStack : public Stack<T> |
1
|
49 { |
2571
|
50 private: |
|
51 |
1
|
52 SLList<T> p; |
|
53 |
2571
|
54 public: |
|
55 |
|
56 SLStack (void) : p () { } |
|
57 |
|
58 SLStack (const SLStack<T>& s) : p (s.p) { } |
|
59 |
|
60 ~SLStack (void) { } |
1
|
61 |
2580
|
62 SLStack<T>& operator = (const SLStack<T>& s); |
2571
|
63 |
|
64 void push (const T& item) { p.prepend (item); } |
1
|
65 |
2571
|
66 T pop (void) { return p.remove_front (); } |
|
67 |
|
68 T& top (void) { return p.front (); } |
|
69 |
|
70 void del_top (void) { p.del_front (); } |
|
71 |
|
72 int empty (void) { return p.empty (); } |
1
|
73 |
2571
|
74 int full (void) { return 0; } |
|
75 |
|
76 int length (void) { return p.length (); } |
1
|
77 |
2571
|
78 void clear (void) { p.clear (); } |
1
|
79 |
2571
|
80 int OK (void) { return p.OK (); } |
1
|
81 }; |
|
82 |
|
83 #endif |
240
|
84 |
|
85 /* |
|
86 ;;; Local Variables: *** |
|
87 ;;; mode: C++ *** |
|
88 ;;; End: *** |
|
89 */ |