首页 > 代码库 > 队列的数组实现

队列的数组实现


#include <stdio.h>
#define maxn 1000

//队列ADT---数组实现
struct queueRecord;
typedef struct queueRecord *Queue;
typedef int elementType;

int isEmpty(Queue Q);
int isFull(Queue Q);
Queue creatQueue(int maxn);
void disposeQueue(Queue Q);
void makeEmpty(Queue Q);
void enqueue(elementType x, Queue Q); //element type
elementType front(Queue Q);
void dequeue(Queue Q);
elementType frontAndDequeue(Queue Q);

struct queueRecord{
	int capacity;
	int front;
	int rear;
	int size;
	ElementType *arr;
};
/*---以上是队列的类型声明---*/

int isEmpty(Queue Q){
	return Q->size == 0;
}

void makeEmpty(Queue Q){
	Q->size = 0;
	Q->front = 1;
	Q->rear = 0;
}

static int succ(int value, Queue Q){
	if(++value =http://www.mamicode.com/= Q->capacity)>