updated filestructure and gitignore. uploading exam progress

This commit is contained in:
Christopher Sanden
2025-11-05 20:09:06 +01:00
parent 729d69a399
commit 1ec6da4771
106 changed files with 12960 additions and 7 deletions

View File

@@ -0,0 +1,36 @@
#include "TStack.h"
#include <stdexcept>
void TStack::Push(const TAction& action)
{
if (top >= STACK_MAX_SIZE)
throw std::overflow_error("Stack overflow");
event[top++] = action;
}
TStack::TAction TStack::Pop()
{
if (top == 0)
throw std::underflow_error("Stack empty");
return event[--top];
}
TStack::TAction TStack::Peek() const
{
if (top == 0)
throw std::underflow_error("Stack empty");
return event[top - 1];
}
bool TStack::IsEmpty() const
{
return top == 0;
}
void TStack::Clear()
{
for (int i = 0; i < top; i++) {
this->Pop();
}
}