-
Notifications
You must be signed in to change notification settings - Fork 0
/
Stacks.cpp
59 lines (50 loc) · 1020 Bytes
/
Stacks.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#ifndef Stacks_CPP_
#define Stacks_CPP_
#include "Stacks.h"
#include <iostream>
using namespace std;
template <class T>
T Stacks<T>::pop(){
T data = list.TAIL();
list.RemoveTail();
return data;
}
template <class T>
void Stacks<T>::push(T item){
// cout << list << endl;
list.insertAfter(item);
// cout << list << endl;
}
template <class T>
bool Stacks<T>::empty(){
if(list.Size() == 0)
return true;
else
return false;
}
template <class T>
int Stacks<T>::size() {
// cout << list.Size() << endl;
return list.Size();
}
template <class T>
T Stacks<T>::top() const{
return list.TAIL();
}
template <class T>
T& Stacks<T>::seek(size_type n) {
// cout << "print" << endl;
// cout << n << " "<< endl;
return list.target(n);
}
template <class T>
T Stacks<T>::print(std::ostream &output){
output << list << endl;
return output;
}
template <class T>
T& Stacks<T>::operator*() const {
// cout <<"work*"<< endl;
return *this->data;
}
#endif