queue.h.svn-base

来自「AVR单片机下」· SVN-BASE 代码 · 共 44 行

SVN-BASE
44
字号
/*                ****ROBOCON 2009 | BUPT TEAM*******
 * ------------------------------------------------------------------------
 * FileName   : queue.h
 * Version    : 1.1
 * Brief      : Queue Data Structure, Header file
 * Code by    : Leaf
 * Date       : Dec 08, 2008
 * Note       : Use Circle Array
 *
 *
 * ------------------------------------------------------------------------
 */

#ifndef QUEUE_H_INCLUDED
#define QUEUE_H_INCLUDED

#include "includes.h"

#ifndef Q_DATA_TYPE
#define Q_DATA_TYPE UINT8
#endif
#ifndef Q_SIZE_TYPE
#define Q_SIZE_TYPE UINT8
#endif
typedef struct
{
      Q_DATA_TYPE *buf;
      Q_SIZE_TYPE capacity;
      Q_SIZE_TYPE front;
      Q_SIZE_TYPE back;
      Q_SIZE_TYPE size;
}Queue;

extern void qInit(Queue *q, Q_DATA_TYPE *buf, Q_SIZE_TYPE bufsize);
extern inline BOOL qFull(const Queue *q);
extern inline BOOL qEmpty(const Queue *q);
extern inline Q_SIZE_TYPE qSize(const Queue *q);
extern void qPush(Queue *q, Q_DATA_TYPE d);
extern Q_DATA_TYPE qPop(Queue *q);
extern Q_DATA_TYPE qFront(const Queue *q);
extern Q_SIZE_TYPE qFlush(Queue *q, Q_DATA_TYPE *buf);
extern void qReset(Queue *q);
#endif

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?