/*
* Queue.h
*
* Created on: 2011-10-7
* Author: Admin
*/
#ifndef QUEUE_H_
#define QUEUE_H_
#include <stdio.h>
#include <stdlib.h>
/* the data type that contained in the queue */
typedef int QueueData;
typedef struct _queue{
size_t length; /* queue length */
size_t capacity; /* queue capacity */
size_t index; /* get data index */
size_t push_index; /* insert index */
QueueData *data; /* the data that queue contain */
}Queue, *pQueue;
/* initialize queue */
void queue_init(pQueue* ptr, size_t size);
/* free memory which the queue own*/
void queue_destroy(pQueue* ptr);
/* add data to queue */
int queue_push(pQueue ptr, QueueData val);
/* dequeue */
QueueData queue_pop(pQueue ptr);
/* get data at front of the queue */
QueueData queue_top(pQueue ptr);
/* return the size of queue */
size_t queue_size(pQueue ptr);
#endif /* QUEUE_H_ */
/*
* Queue.c
*
* Created on: 2011-10-7
* Author: Admin
*/
#include <s
C语言队列实现( 动态数组 )
最新推荐文章于 2021-01-02 21:44:05 发布