下面是我的教授幻灯片,我的数据结构类的一种工作,我一直在做研究,不能在这里弄清楚概念,我在此建立一个程序的问题,我数据结构类。我有了解如何与队列
.back是什么?什么是我们发送到下面的实际功能: 请解释一下像我一个6岁的...
ADT-队列(工具包功能的数组实现)
//Create a q.
void create_queue(Queue & q)
{
q.back = -1;
}
//check if Queue is empty
int empty(const QUEUE & q)
{
return (q.back == -1);
}
//Purge elements in the queue
void purge(Queue & q)
{
q.back = -1;
}
//Add an element on the q.
void enq(Queue & q, CONST INFOREC & item)
{
++ q.back;
q.i[q.back] = item; // i is an array of ints previously declared
}
// delete an item from the q
void deq(Queue &q, INFOREC & item)
{
int ct;
item =q.i[0]; front;
// step forward loop, moving the entire array components 1 place forward and
// shifting the pointers
for (ct = 1; ct < q.back; ++ct);
q.i[ct -1] = q.i [ct];
--q.back;
}
请问您能正确格式化您的代码吗? – Patashu 2013-03-21 03:30:38
您似乎在该代码中有一些未标记的注释...还有一些案例问题:是否应将“QUEUE”和“Queue”等同起来? – 2013-03-21 03:30:38
你有更多的代码示例和/或幻灯片吗? – 2013-03-21 03:33:44