This repository has been archived on 2021-11-03. You can view files and clone it, but cannot push or open issues or pull requests.
2019-12-12 15:56:38 +01:00
|
|
|
#include <iostream>
|
|
|
|
#include "Stack.hh"
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Dynamically Sized Stack Implementation
|
|
|
|
*/
|
|
|
|
using namespace std ;
|
|
|
|
|
|
|
|
int main() {
|
2020-06-30 11:18:10 +02:00
|
|
|
Stack s(5) ;// initialize Stack
|
2019-12-12 15:56:38 +01:00
|
|
|
|
|
|
|
// Write doubles into Stack
|
|
|
|
int i ;
|
|
|
|
for (i=0 ; i<15 ; i++) {
|
|
|
|
cout << "pushing value " << i*i << " in stack" << endl ;
|
|
|
|
s.push(i*i) ;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Count doubles in fifo
|
2020-06-30 11:18:10 +02:00
|
|
|
cout << s.nitems() << " values in Stack" << endl ;
|
2019-12-12 15:56:38 +01:00
|
|
|
|
|
|
|
cout << "Inspect the FIFO" << endl;
|
|
|
|
s.inspect();
|
|
|
|
|
|
|
|
|
|
|
|
// Read doubles back from fifo
|
|
|
|
while (!s.empty()) {
|
|
|
|
double val = s.pop() ;
|
2020-06-30 11:18:10 +02:00
|
|
|
cout << "popping value " << val << " from Stack" << endl ;
|
2019-12-12 15:56:38 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
cout << "Inspect the FIFO" << endl;
|
|
|
|
s.inspect();
|
|
|
|
return 0 ;
|
|
|
|
}
|