Binary Search Tree (C++)
Loading...
Searching...
No Matches
Stack.h
Go to the documentation of this file.
1
20
21#pragma once
22
23#ifndef STACK_H
24#define STACK_H
25
26#include "Node.h"
27
45
54struct StackNode {
55 Node* data;
56 StackNode* next;
57
62 StackNode(Node* data) : data(data), next(nullptr) {}
63};
64
65class Stack {
66public:
71 Stack() : top(nullptr) {}
72
76 ~Stack();
77
82 void push(Node* n);
83
88 Node* pop();
89
94 bool isEmpty() const;
95
96private:
97 StackNode* top;
98};
99
100#endif // STACK_H
Declaration of the Node class.
Represents a node within a binary search tree.
Definition Node.h:35
Stack()
Constructs an empty Stack.
Definition Stack.h:71
~Stack()
Destroys the Stack.
Definition Stack.cpp:21
Node * pop()
Removes and returns the node at the top of the stack.
Definition Stack.cpp:40
bool isEmpty() const
Checks whether the stack is empty.
Definition Stack.cpp:52
void push(Node *n)
Pushes a node onto the stack.
Definition Stack.cpp:31
Internal node type used by the Stack class.
Definition Stack.h:54
StackNode(Node *data)
Constructs a StackNode with the specified node pointer.
Definition Stack.h:62