c++ 循环队列

x33g5p2x  于2022-01-09 转载在 C/C++  
字(0.8k)|赞(0)|评价(0)|浏览(462)
  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

相关文章

最新文章

更多