39 lines
894 B
C
39 lines
894 B
C
|
#ifndef _RING_QUEUE_H_
|
|||
|
#define _RING_QUEUE_H_
|
|||
|
|
|||
|
//#include "common.h"
|
|||
|
//#define RING_QUEUE_DEBUG //<2F><><EFBFBD>屾<EFBFBD><E5B1BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӡRingQueue<75>ĵ<EFBFBD><C4B5><EFBFBD><EFBFBD><EFBFBD>Ϣ
|
|||
|
|
|||
|
#define RQ_OK 1
|
|||
|
#define RQ_ERROR 0
|
|||
|
#define RQ_OVERFLOW -2
|
|||
|
typedef unsigned char RQ_ElementType;//Ԫ<><D4AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
|||
|
typedef struct _ring_queue
|
|||
|
{
|
|||
|
RQ_ElementType *elems;
|
|||
|
int size;
|
|||
|
volatile int front, rear;
|
|||
|
}RingQueue;
|
|||
|
|
|||
|
//<2F><>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,<2C>贫<EFBFBD>뱣<EFBFBD><EBB1A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>״̬<D7B4>Ľṹq<E1B9B9><71><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʹ<EFBFBD>õ<EFBFBD>buffer<65><72>buffer<65><72>С
|
|||
|
int InitRingQueue(RingQueue *q, RQ_ElementType *buff, int size);
|
|||
|
|
|||
|
#define RingQueueFull(q) (((q)->rear+1) % (q)->size == (q)->front)
|
|||
|
#define RingQueueEmpty(q) ((q)->front == (q)->rear)
|
|||
|
|
|||
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,
|
|||
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʹ<EFBFBD>ã<EFBFBD><C3A3>ʶ<EFBFBD><CAB6><EFBFBD><EFBFBD><EFBFBD><EFBFBD>߿<EFBFBD><DFBF><EFBFBD><EFBFBD>ĵ<DEB8>rear<61>ȶ<EFBFBD>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD>
|
|||
|
int ShowRingQueue(RingQueue *q);
|
|||
|
|
|||
|
//<2F><><EFBFBD><EFBFBD>β<EFBFBD><CEB2><EFBFBD><EFBFBD>Ԫ<EFBFBD><D4AA>e
|
|||
|
int InRingQueue(RingQueue *q,RQ_ElementType e);
|
|||
|
|
|||
|
//<2F>Ӷ<EFBFBD><D3B6><EFBFBD>ɾ<EFBFBD><C9BE>Ԫ<EFBFBD><D4AA>
|
|||
|
int OutRingQueue(RingQueue *q, RQ_ElementType *e);
|
|||
|
|
|||
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>е<EFBFBD>Ԫ<EFBFBD>ظ<EFBFBD><D8B8><EFBFBD>
|
|||
|
int RingQueueLength(RingQueue *q);
|
|||
|
|
|||
|
#endif
|