赞
踩
故名思意,就是不论从那边看都是一个队列。(我觉得像是两个栈,栈底拼在一起),两端都能进行插入和删除。
双向队列也是基于线性表的,因此数组和链表都可以实现它,在此我就仅用链表实现一下。
typedef int ELemType; //用int来模拟数据项类型 typedef struct Node//数据节点 { ELemType data; struct Node* pre; struct Node* next; }*DuList; typedef struct { int size; DuList front; DuList back; }Deque;
int Size_Deque(Deque* D)
{
assert(D != NULL);
return D->size;
}
bool Init_Deque(Deque* D)
{
assert(D != NULL);
D->size = 0;
D->front = NULL;
D->back = NULL;
return true;
}
bool Clear_Deque(Deque* D)
{
assert(D != NULL);
while (!IsEmpty_Deque(D))
{
Pop_Front_Deque(D)
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。