C封装基于双向链表的队列对象
DoubleLinkedListQueue双链队列
队列的结点数据结构定义如下:
1 | typedef struct DLLQNode{ |
队列的对象数据结构定义如下:
1 | typedef struct DLLQueue{ |
DLLQueue.c
1 | #include <stdio.h> |
DLLQueue.h
1 | /* Define to prevent recursive inclusion -------------------------------------*/ |
为了方便在其他的工程代码里对不同元素类型使用DLLQueue,我把ElemTypeDefine抽取出来单独放在一个头文件里。这样,想要适用不同元素类型的DLLQueue,只要修改ElemTypeDefine.h里的 DLLQElemType定义即可。默认的元素类型为int。
ElemTypeDefine.h文件
1 | /* Define to prevent recursive inclusion -------------------------------------*/ |
testDLLQueue.c文件
1 | #include <stdio.h> |
编译:
1 | gcc DLLQueue.c testDLLQueue.c -o testDLLQueue |
执行testDLLQueue:
1 | is DLLQueue empty:1 |
本文标题:C封装基于双向链表的队列对象
文章作者:Mr Bluyee
发布时间:2018-09-26
最后更新:2019-07-15
版权声明:The author owns the copyright, please indicate the source reproduced.