KyosoTechnology / Queue

queueEx.h

Committer:
masaaki_makabe
Date:
2021-11-22
Revision:
1:07cddbd29781
Child:
2:68ce6bdc0714

File content as of revision 1:07cddbd29781:

/**
  ******************************************************************************
  * @file           : queueEx.h
  * @brief          : queue expansion
  ******************************************************************************
  * @attention
  *
  ******************************************************************************
  */
#ifndef QUEUEEX_h
#define QUEUEEX_h

#include "queue.h"

class QueueEx : public Queue{
private:
public:
    QueueEx(int iSize, int iCount) : Queue(iSize, iCount){
    }
    bool Peek(int index, void* pvItem){
        unsigned char *p = m_pnRdIndex;
        if (index < m_iLclCount){
            for(int i = 0; i < index; i++){
                p += m_iSize;
                if ( p >= m_pnTail ) p = m_pnHead;
            }
            memcpy( pvItem, p, m_iSize );
            return true;
        }
        return false;
    }
};

#endif/*QUEUEEX_h*/