-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathActionStack.h
More file actions
49 lines (43 loc) · 1.13 KB
/
ActionStack.h
File metadata and controls
49 lines (43 loc) · 1.13 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
/*
* ActionStack.h
*
* CS15 Proj 2: Typewriter
*
* Interface for the ActionStack class.
*
* Author: Milod Kazerounian (Sept 2025)
*/
#ifndef __ACTIONSTACK_H__
#define __ACTIONSTACK_H__
#include <vector>
#include <stdexcept>
#include <cstddef>
class ActionStack {
public:
/* The ActionStack will store Action instances, which capture actions
* performed by the user. An Action comprises of: a `character`,
* a bool denoting whether or not that character was `deleted`, and
* a `line` and `column` for the character.
*/
struct Action {
char character;
bool deleted;
std::size_t line;
std::size_t column;
};
/* Constructor, destructor, and member functions.
* See the spec for the expected behavior of each of these.
*/
ActionStack();
~ActionStack();
bool isEmpty() const;
int size() const;
Action top() const;
void pop();
void push(Action elem);
void push(char c, bool was_delete, std::size_t line, std::size_t column);
void clear();
private:
std::vector<Action> data; // underlying container for stack behavior
};
#endif