-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstack.h
44 lines (36 loc) · 984 Bytes
/
stack.h
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
#ifndef STACK_H
#define STACK_H
#include "linked_list.h"
// #include "linked_list.cpp"
template <class T>
class Stack{
private:
size_t capacity;
size_t size;
T *stack;
T *top;
public:
// Constructors
Stack();
Stack(int capacity);
Stack(int size, T arr[]);
Stack(int capacity, const LinkedList<T>& ll);
Stack(const Stack<T> &stack); // Copy Constructor
// Accessors (Getters)
T peek() const;
int getSize() const;
int getCapacity() const;
// Enquiry Functions
bool isEmpty() const;
// Mutators (Setters)
T pop();
void push(T ele);
// Facilitators
void display() const;
// Operator Overloads
template<class U>
friend std::ostream &operator<<(std::ostream &cout, const Stack<U> &stack);
// Destructors
~Stack();
};
#endif