-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathStack.h
43 lines (34 loc) · 1.03 KB
/
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
/**
* @file Stack.h
* @brief Contains the stack class definitions
*
* Contains the definition of the stack class and the node struct.
* The stack class is used to store tasks in a LIFO order.
* Includes a top method to access the top task without popping.
*
* @date 10/31/24
* @author Marcello Novak
*/
#pragma once
#include "Task.h"
struct StackNode {
Task taskData;
StackNode* nextTask;
StackNode* prevTask; // It's doubly linked so I can print it easier
};
class Stack {
private:
StackNode* head; // Top of the stack
StackNode* tail; // Bottom of the stack (new)
public:
// Constructor and Destructor
Stack();
~Stack();
// Push and Pop methods
void push(Task task);
void pop();
Task* top(); // Pointer for top task, so it can be accessed without popping
bool isEmpty(); // Bool to check if the stack is empty
void printStack(); // Function to print the stack
void runExample(); // Function to run the example
};