-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstack.h
More file actions
61 lines (46 loc) · 2.38 KB
/
Copy pathstack.h
File metadata and controls
61 lines (46 loc) · 2.38 KB
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
60
61
#ifndef STACK_H
#define STACK_H
#include <iostream>
#include <vector>
namespace cop4530 {
template <typename T>
class Stack {
public:
// Zero argument constructor
explicit Stack(int initSize = 0);
~Stack (); // Destructor
Stack (const Stack<T>& rhs); // Copy Constructor
Stack(Stack<T> && rhs); // Move Constructor
Stack<T>& operator= (const Stack <T>& rhs); // Coppy assignment operator
Stack<T> & operator=(Stack<T> && rhs); // Move assignment operator
bool empty() const; // Returns true if the stack contains no elements
void clear(); // Deletes every element from the stack
int size() const; // Returns the number of elements in the stack
void push(const T& x); // Adds "x" onto the stack (copy version)
void push(T && x); // Adds "x" onto the stack (move version)
void pop(); // Removes the most recently added element from the stack
T& top(); // Returns the reference to the most recently added element
const T& top() const; // Returns the most recently added element of the stack
// Prints elements of the stack to the ostream "os"
void print(std::ostream& os, char ofc = ' ') const;
private:
int theSize; // Number of elements
int totalCapacity; // Total capacity
std::vector<T> vec; // A vector of type 'T' elements
};
// Prints the stack
template <typename T>
std::ostream& operator<< (std::ostream& os, const Stack<T>& a);
// Returns true if the two stacks have the same elements in the same order.
template <typename T>
bool operator== (const Stack<T>& lhs, const Stack <T>& rhs );
/* Returns true if the two stacks are not in the
same order and/or do not have the same elements*/
template <typename T>
bool operator!= (const Stack<T>& lhs, const Stack <T>& rhs);
// Returns true if every element in the stack 'a' is less than or equal to 'b'
template <typename T>
bool operator<= (const Stack<T>& lhs, const Stack <T>& rhs);
#include "stack.hpp"
}
#endif