双端队列部分操作(剩下部分待补)
2012-09-01 22:00
288 查看
/* 双端队列操作 */ #define MAX_QUEUE_SIZE 100 #define TRUE 1 #define FALSE 0 #define IS_QUEUE_EMPTY(front, rear) (front == rear ? TRUE: FALSE) #define IS_QUEUE_FULL(rear) ((rear == MAX_QUEUE_SIZE - 1 && front == 0) ? TRUE: FALSE)) int front = MAX_QUEUE_SIZE / 2, rear = MAX_QUEUE_SIZE / 2; typedef struct info{ int key; /* other fields */ }element; element queue[MAX_QUEUE_SIZE]; void add_double_port_queue(int *front, int *rear, element item) { *rear = (*rear + 1) % MAX_QUEUE_SIZE; if(IS_QUEUE_FULL(front, *rear)){ queue_full(*rear); return ; } if(*rear != MAX_QUEUE_SIZE - 1){ queue[++*rear] = item; return ; } if(*front != 0){ queue[--*front] = item; return ; } } void queue_full(void) { printf("Full.\n"); /* other operations */ return ; }
相关文章推荐
- Javascript实现能够双端操作的循环队列
- deque双端队列的基本操作
- 看完内核中的链表操作部分,写了个通用队列
- c语言:用双向链表实现双端队列(队列两端都可以进行入队出队操作)
- 栈,队列和双端队列的操作
- C++ STL 有关容器部分 priority_queue 优先级队列的基本操作以及认识案例
- 利用顺序存储结构实现双端队列的入队和出队操作
- DELPHI IDE中部分操作快捷方式
- E - 队列的操作
- 队列的基本操作
- 数据结构(十) 链队列的基本操作 ----入队列,出队列,判断队列是否为空
- 数据模型所描述的内容包括三个部分:数据结构、数据操作、数据约束。
- switch分解试验部分-LAB2:交换机端口操作模式设置
- 【通过操作指针,与指针做函数參数'实现字串在主串中出现的次数,然后将出现的部分依照要求进行替换 】
- 二叉查找树的各项操作(重点是结点的删除部分和递归的运用)
- 2457: [BeiJing2011]双端队列
- STL中栈和队列的基本操作
- jquery中得dom操作(部分)
- 栈和队列(思想+伪代码+部分代码)
- c++ -- 栈和队列的基本操作