#include <Stack.hpp>
Public Methods | |
| Stack () | |
| Stack (DBase *item) | |
| Stack (const Stack &stk) | |
| void | push (DBase *item) |
| DBase * | pop () |
| DBase & | topValue () const |
| void | clear () |
| void | display () const |
| virtual | ~Stack () |
| int | getSize () const |
| bool | isEmpty () const |
| bool | isNotEmpty () const |
Private Attributes | |
| Link * | top |
| int | size |
|
|
Definition at line 4 of file Stack.cpp. 00004 { // Default Constructor
00005 top = NULL;
00006 size = 0;
00007 }
|
|
|
Definition at line 9 of file Stack.cpp. 00009 { // First item Constructor
00010 top = new Link( item, NULL );
00011 size = 1;
00012 }
|
|
|
Definition at line 14 of file Stack.cpp. 00014 { // Copy Constructor
00015 Link* fromCurr = stk.top;
00016 Link* toCurr = new Link( *fromCurr );
00017
00018 top = toCurr; // Setting the top pointer
00019 size = 1;
00020
00021 while ( fromCurr->next != NULL ) { // Is it the end of the from Stack ?
00022
00023 fromCurr = fromCurr->next; // Move forward in the reading stack
00024
00025 toCurr->next = new Link( *fromCurr ); // Copy the next Link content
00026
00027 toCurr = toCurr->next; // Move forward in the writing stack
00028 size++; // We just added a new Link
00029 }
00030
00031 if ( size != stk.size ) {
00032 cout << "An error occured while copying the Stack to a new Stack\n";
00033 }
00034 }
|
|
|
Definition at line 32 of file Stack.hpp. 00032 { // Destructor
00033 clear();
00034 }
|
|
|
Definition at line 56 of file Stack.cpp. Referenced by ~Stack().
|
|
|
Definition at line 75 of file Stack.cpp. 00075 {
00076 Link* curr = top;
00077
00078 if ( isEmpty() ) // If it's empty then get out.
00079 return;
00080
00081 while ( curr->next != NULL ) { // Is it the end of the from Stack ?
00082
00083 curr->element->display();
00084 curr = curr->next; // Move forward in the reading stack
00085 }
00086
00087 }
|
|
|
Definition at line 36 of file Stack.hpp. 00036 {
00037 return size;
00038 }
|
|
|
Definition at line 40 of file Stack.hpp. Referenced by clear(), display(), pop(), and topValue().
00040 { // The Stack is empty ?
00041 return ( top == NULL ) || ( size < 1 );
00042 }
|
|
|
Definition at line 44 of file Stack.hpp. Referenced by Parenth::read().
00044 { // The Stack is not empty ?
00045 return ( top != NULL ) && ( size > 0 );
00046 }
|
|
|
Definition at line 41 of file Stack.cpp. Referenced by Parenth::read().
|
|
|
Definition at line 36 of file Stack.cpp. Referenced by Parenth::read().
00036 { // Insert an item at the top
00037 top = new Link( item, top );
00038 size++;
00039 }
|
|
|
|
|
|
Definition at line 51 of file Stack.hpp. Referenced by Stack().
|
|
|
Definition at line 50 of file Stack.hpp. Referenced by Stack().
|
1.2.11.1 written by Dimitri van Heesch,
© 1997-2001