extended_queue.cpp

来自「包括图、二叉树、链表」· C++ 代码 · 共 41 行

CPP
41
字号
#include "Extended_queue.h"

Error_code Extended_queue::serve_and_retrieve(Queue_entry &item)
/*
Post: The front of the Queue is removed and reported
in item. If the Queue
is empty return an Error_code
of underflow and leave the Queue unchanged.
*/
{
	if (front == NULL) return underflow;
	Node *old_front = front;
	item = old_front->entry;
	front = old_front->next;
	if (front == NULL) rear = NULL;
	delete old_front;
	return success;
}
bool Extended_queue::full() const
{
	return false;
}
void Extended_queue::clear()
{
	while (!empty())
		serve();
}
int Extended_queue::size() const
/*
Post: Return the number of entries in the Extended_queue.
*/
{
	Node *window = front;
	int count = 0;
	while (window != NULL) {
		window = window->next;
		count++;
	}
	return count;
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?