c++ 循环队列

举报
风吹稻花香 发表于 2022/01/11 01:01:14 2022/01/11
【摘要】 #ifndef __CIRCLEQUEUE_H__#define __CIRCLEQUEUE_H__#include <stdlib.h>#include <string.h>#include <pthread.h> #undef CIRCLEQUEUE_DEBUG #include <an...


  
  1. #ifndef __CIRCLEQUEUE_H__
  2. #define __CIRCLEQUEUE_H__
  3. #include <stdlib.h>
  4. #include <string.h>
  5. #include <pthread.h>
  6. #undef CIRCLEQUEUE_DEBUG
  7. #include <android/log.h>
  8. #define TRANSFER_LOG_TAG "CIRCLEQUEUE"
  9. #define LOGI(...) __android_log_print(ANDROID_LOG_INFO,TRANSFER_LOG_TAG,__VA_ARGS__)
  10. #define LOGE(...) __android_log_print(ANDROID_LOG_ERROR,TRANSFER_LOG_TAG,__VA_ARGS__)
  11. template <typename ElemType>
  12. class CircleQueue {
  13. public:
  14. CircleQueue(int capacity, const char *name, bool circulation);
  15. ~CircleQueue();
  16. bool isQueueFull();
  17. bool isQueueEmpty();
  18. bool enQueue(ElemType element);
  19. bool deQueue(ElemType &element);
  20. bool getLastQueue(ElemType &element);
  21. void Lock();
  22. void unLock();
  23. int getLength();
  24. int getCapacity();
  25. private:
  26. char queue_name[128];
  27. ElemType *data;
  28. int m_queueCapacity;
  29. int m_queueLength;
  30. int readPos;
  31. int writePos;
  32. bool isCirculative;
  33. p

文章来源: blog.csdn.net,作者:AI视觉网奇,版权归原作者所有,如需转载,请联系作者。

原文链接:blog.csdn.net/jacke121/article/details/122389301

【版权声明】本文为华为云社区用户转载文章,如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱: cloudbbs@huaweicloud.com
  • 点赞
  • 收藏
  • 关注作者

评论(0

0/1000
抱歉,系统识别当前为高风险访问,暂不支持该操作

全部回复

上滑加载中

设置昵称

在此一键设置昵称,即可参与社区互动!

*长度不超过10个汉字或20个英文字符,设置后3个月内不可修改。

*长度不超过10个汉字或20个英文字符,设置后3个月内不可修改。