Completed BST and most of infrastructure for the whole section

This commit is contained in:
Christopher Sanden
2025-11-07 22:27:11 +01:00
parent e761ac0e23
commit d6d627adad
13 changed files with 449 additions and 22 deletions

View File

@@ -6,7 +6,8 @@ add_library(SharedLib STATIC
TPerson.cpp
TPerson.h
TLinkedList.cpp
TLinkedList.h)
TLinkedList.h
../Assignment-03/TEmployee.h)
# --- Step 2: Add Header Files to the Library ---
@@ -18,7 +19,7 @@ target_sources(SharedLib
SharedLib.h
TDoublyLinkedList.h
TStack.h
TQueue.h
TTreeQueue.h
Utils.h
# Or add other shared files here
PRIVATE
@@ -28,7 +29,7 @@ target_sources(SharedLib
FileReaderUtils.cpp
TDoublyLinkedList.cpp
TStack.cpp
TQueue.cpp
TTreeQueue.cpp
Utils.cpp
)

View File

@@ -1,9 +1,9 @@
#include "TQueue.h"
#include "TTreeQueue.h"
#include <stdexcept>
void TQueue::Enqueue(const std::string& text)
void TTreeQueue::Enqueue(const std::string& text)
{
if (IsFull())
throw std::overflow_error("Queue Overflow");
@@ -12,7 +12,7 @@ void TQueue::Enqueue(const std::string& text)
count++;
}
std::string TQueue::Dequeue()
std::string TTreeQueue::Dequeue()
{
if (IsEmpty())
throw std::underflow_error("Empty Queue");
@@ -22,24 +22,24 @@ std::string TQueue::Dequeue()
return item;
}
std::string TQueue::Peek() const
std::string TTreeQueue::Peek() const
{
if (IsEmpty())
throw std::underflow_error("Empty Queue");
return queue[head];
}
bool TQueue::IsEmpty() const
bool TTreeQueue::IsEmpty() const
{
return count == 0;
}
bool TQueue::IsFull() const
bool TTreeQueue::IsFull() const
{
return count == MAX_SIZE;
}
int TQueue::GetTail() const
int TTreeQueue::GetTail() const
{
if (IsEmpty())
throw std::underflow_error("Empty Queue");

View File

@@ -5,7 +5,8 @@
#include "TDoublyLinkedList.h"
class TQueue {
class TTreeQueue {
private:
std::string queue[MAX_SIZE];
int head = 0;
@@ -13,8 +14,8 @@ private:
int count = 0;
public:
TQueue() = default;
~TQueue() = default;
TTreeQueue() = default;
~TTreeQueue() = default;
void Enqueue(const std::string& text);
std::string Dequeue();