add queue debug messages
This commit is contained in:
@ -1,9 +1,9 @@
|
|||||||
#include "Queue.h"
|
#include "Queue.h"
|
||||||
|
#include "kernel/Globals.h"
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
// #include <iostream>
|
|
||||||
|
|
||||||
void Queue::enqueue(Chain* item) {
|
void Queue::enqueue(Chain* item) {
|
||||||
// std::cout << "Enqueue " << item->val << std::endl;
|
// kout << "Enqueue " << (unsigned int)item << endl;
|
||||||
|
|
||||||
*this->tail = item; // If queue is empty tail points to head pointer,
|
*this->tail = item; // If queue is empty tail points to head pointer,
|
||||||
this->tail = &item->next; // otherwise to last next pointer
|
this->tail = &item->next; // otherwise to last next pointer
|
||||||
@ -12,7 +12,7 @@ void Queue::enqueue(Chain* item) {
|
|||||||
Chain* Queue::dequeue() {
|
Chain* Queue::dequeue() {
|
||||||
if (this->isEmpty()) {
|
if (this->isEmpty()) {
|
||||||
// This should not ever happen as the idle thread exists always
|
// This should not ever happen as the idle thread exists always
|
||||||
// std::cout << "Dequeue called on empty queue." << std::endl;
|
// kout << "Dequeue called on empty queue." << endl;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -26,14 +26,14 @@ Chain* Queue::dequeue() {
|
|||||||
this->tail = &this->head;
|
this->tail = &this->head;
|
||||||
}
|
}
|
||||||
|
|
||||||
// std::cout << "Dequeue " << item->val << std::endl;
|
// kout << "Dequeue " << (unsigned int)item << endl;
|
||||||
|
|
||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Queue::remove(Chain* item) {
|
void Queue::remove(Chain* item) {
|
||||||
if (this->isEmpty()) {
|
if (this->isEmpty()) {
|
||||||
// std::cout << "Remove called on empty queue" << std::endl;
|
// kout << "Remove called on empty queue" << endl;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -41,7 +41,7 @@ void Queue::remove(Chain* item) {
|
|||||||
Chain* lastnext = NULL;
|
Chain* lastnext = NULL;
|
||||||
while (current != item) {
|
while (current != item) {
|
||||||
if (current->next == *this->tail) {
|
if (current->next == *this->tail) {
|
||||||
// std::cout << "Element not in queue." << std::endl;
|
// kout << "Element not in queue." << endl;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -72,22 +72,22 @@ void Queue::remove(Chain* item) {
|
|||||||
void Queue::print() const {
|
void Queue::print() const {
|
||||||
if (this->isEmpty()) {
|
if (this->isEmpty()) {
|
||||||
// Queue is empty
|
// Queue is empty
|
||||||
// std::cout << "List is empty!" << std::endl;
|
kout << "List is empty!" << endl;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// std::cout << "List: ";
|
kout << "List: ";
|
||||||
|
|
||||||
Chain* current = this->head;
|
Chain* current = this->head;
|
||||||
// std::cout << current->val << " "; // At least one element in queue
|
kout << (unsigned int)current << " "; // At least one element in queue
|
||||||
|
|
||||||
while (current->next != *this->tail) {
|
while (current->next != *this->tail) {
|
||||||
// More than one element in queue
|
// More than one element in queue
|
||||||
current = current->next;
|
current = current->next;
|
||||||
// std::cout << current->val << " ";
|
kout << (unsigned int)current << " ";
|
||||||
}
|
}
|
||||||
|
|
||||||
// std::cout << std::endl;
|
kout << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Queue::isEmpty() const {
|
bool Queue::isEmpty() const {
|
||||||
|
|||||||
Reference in New Issue
Block a user