all done, just adding tests for redundancy

This commit is contained in:
2026-03-17 15:36:27 -06:00
parent 3dd365012c
commit c56cc5dca2
5 changed files with 242 additions and 15 deletions

View File

@@ -39,11 +39,9 @@ public:
template <typename T>
requires std::formattable<T, char>
Stack<T>::Stack() {
Stack<T> new_stack;
new_stack.data = new T[DEFAULT_STACK_SIZE];
new_stack.cap = 0;
new_stack.len = 0;
return new_stack;
this->data = new T[DEFAULT_STACK_SIZE];
this->cap = DEFAULT_STACK_SIZE;
this->len = 0;
}
template <typename T>
@@ -109,7 +107,7 @@ std::expected<T, StackErr> Stack<T>::pop() {
this->cap = new_capacity;
}
return std::expected(return_val);
return return_val;
}
template <typename T>
@@ -119,7 +117,7 @@ std::expected<T, StackErr> Stack<T>::peek() {
return std::unexpected(StackErr::empty);
}
return std::expected(this->data[this->len - 1]);
return this->data[this->len - 1];
}
template <typename T>
@@ -129,15 +127,15 @@ void Stack<T>::print() {
std::println("Length: {}.", this->len);
std::println("Capacity: {}.", this->cap);
std::println("{:^20}", "Datos");
std::println("{:^20}", "|");
std::println("{:^20}", "v");
std::println("{:^22}", "Datos");
std::println("{:^22}", "|");
std::println("{:^22}", "v");
for (int i = 0; i < this->cap; i++) {
for (uint64_t i = 0; i < this->cap; i++) {
if (i < this->len) {
std::println("{:^20}", this->data[i]);
std::println("[{:^20}]", this->data[i]);
} else {
std::println("{:^20}", "NULL");
std::println("[{:^20}]", "EMPTY");
}
}
}