C封装单链循环队列对象
SingleCircularLinkedListQueue单链循环队列
单链循环队列用单向循环链表实现。
github源码
SingleCircularLinkedListQueue.c文件
1 | #include <stdio.h> |
SingleCircularLinkedListQueue.h文件
1 | /* Define to prevent recursive inclusion -------------------------------------*/ |
testSingleCircularLinkedListQueue.c文件
1 | #include <stdio.h> |
编译:
1 | gcc SingleCircularLinkedListQueue.c SingleCircularLinkedListQueue.h testSingleCircularLinkedListQueue.c -o testSingleCircularLinkedListQueue |
运行testSingleCircularLinkedListQueue:
1 | queue is empty:0 |
queue->traverse(queue,printQnode,0);
int circular = 0 表示队列只从头到尾遍历Qnode一遍;
int circular = 1 表示队列循环遍历Qnode,所以上面程序运行最后进入循环,不断遍历Qnode。
在实现的visit函数中,返回值如果不为0则退出遍历。
上述代码实现的visit函数为printQnode,返回值为0;
本文标题:C封装单链循环队列对象
文章作者:Mr Bluyee
发布时间:2018-09-03
最后更新:2019-07-15
版权声明:The author owns the copyright, please indicate the source reproduced.