以下は、データ構造クラスの教授スライドの 1 つです。私は研究を行っていて、ここで概念を理解できず、データ構造クラスでこれを使用してプログラムを作成する必要があります。
.back は何をしますか? 以下の実際の機能に何を送信していますか: 私が 6 歳のように説明してください...
ADT-Queue (ツールキット関数配列実装)
//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;
}