From e4c74f694752502804de7822fcf0666cef17bfb7 Mon Sep 17 00:00:00 2001 From: LaEntropiaa Date: Tue, 17 Mar 2026 21:10:03 -0600 Subject: [PATCH] added print with indications and all, based on a design for another proyect --- include/queue.h | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/include/queue.h b/include/queue.h index 904f91a..6e1cd35 100644 --- a/include/queue.h +++ b/include/queue.h @@ -36,7 +36,7 @@ public: std::expected dequeue(); - void display(); + void print(); }; template @@ -147,4 +147,34 @@ std::expected Queue::peek() { return out; } + +template +requires std::formattable +void Queue::print() { + if (this->len == 0) { + std::println("Queue is empty."); + return; + } + + std::println("Lenght: {}", this->len); + std::println("Capacity: {}", this->cap); + for (uint64_t i = 0; i < this->cap; i++) { + if (this->tail == this->head) { + std::println("H/T --->"); + } else if (this->tail == i) { + std::println("Tail--->"); + } else if (this->head == i) { + std::println("Head--->"); + } else { + std::println("|{:^20}|", ""); + } + + uint64_t dist = (i + this->cap - this->tail) % this->cap; + if (dist < this->len) { + std::println("|{:^20}|", this->data[i]); + } else { + std::println("|{:^20}|", ""); + } + } +} #endif // !QUEUE_H