»õ ÆÄÀÏ |
| | |
| | | #pragma once |
| | | |
| | | |
| | | #include "akSTLLinker.h" |
| | | |
| | | template <typename T> |
| | | class CakQueueCircle |
| | | { |
| | | public: |
| | | CakQueueCircle(); |
| | | ~CakQueueCircle(); |
| | | |
| | | |
| | | void clear(); //ë©ëª¨ë¦¬ ìì ë ìë¨ |
| | | void setMemSize(unsigned int memsize); //memsizeê° 0ì¼ë ë©ëª¨ë¦¬ ìì |
| | | |
| | | void pushData(T point); |
| | | void setData( unsigned int nindex , T point ); |
| | | void getData(T* pPointBuffer, unsigned int nBufferLength); |
| | | |
| | | int size(){return m_nPointNum;}; |
| | | |
| | | T& operator [](unsigned int nindex); |
| | | CakQueueCircle& operator= (CakQueueCircle& traj); |
| | | |
| | | //static unsigned int s_TrajectorySize; |
| | | |
| | | |
| | | //ê°ë¥íë©´ ìëì ë©¤ë² ë³ìì ì§ì ìì ì íì§ ë§ê²!! |
| | | public: |
| | | int m_nMemSize; //íë³´ ë©ëª¨ë¦¬ ì¬ì´ì¦ |
| | | int m_nPointIndex; //íì¬ ì¸ë±ì¤ |
| | | int m_nPointNum; //íì¬ ì
ë ¥ë Point ê°¯ì |
| | | T* m_pPoints; //ë°ì´í° ë³ì |
| | | public: |
| | | unsigned long m_nPushCount; |
| | | }; |
| | | |
| | | |
| | | template <typename T> |
| | | CakQueueCircle<T>::CakQueueCircle(void) |
| | | { |
| | | m_pPoints = NULL; |
| | | m_nMemSize = 0; |
| | | m_nPushCount = 0; |
| | | |
| | | clear(); |
| | | setMemSize(100); |
| | | }; |
| | | |
| | | |
| | | template <typename T> |
| | | CakQueueCircle<T>::~CakQueueCircle(void) |
| | | { |
| | | setMemSize(0); |
| | | }; |
| | | |
| | | template <typename T> |
| | | void CakQueueCircle<T>::clear() //ë©ëª¨ë¦¬ ìì ë ìë¨ |
| | | { |
| | | m_nMemSize; //íë³´ ë©ëª¨ë¦¬ ì¬ì´ì¦ |
| | | m_nPointIndex = -1; //íì¬ ì¸ë±ì¤ |
| | | m_nPointNum = 0; //íì¬ ì
ë ¥ë Point ê°¯ì |
| | | //m_pPoints; //ë°ì´í° ë³ì |
| | | m_nPushCount = 0; |
| | | } |
| | | |
| | | template <typename T> |
| | | void CakQueueCircle<T>::setMemSize(unsigned int memsize) //memsizeê° 0ì¼ë ë©ëª¨ë¦¬ ìì |
| | | { |
| | | //clear |
| | | if(m_pPoints != NULL) |
| | | { |
| | | clear(); |
| | | m_nMemSize = 0; |
| | | delete [] m_pPoints; |
| | | m_pPoints = NULL; |
| | | } |
| | | |
| | | if(memsize > 0) |
| | | { |
| | | m_nMemSize = memsize; |
| | | |
| | | m_pPoints = new T [m_nMemSize]; |
| | | } |
| | | |
| | | } |
| | | |
| | | template <typename T> |
| | | void CakQueueCircle<T>::pushData(T point) |
| | | { |
| | | m_nPointIndex++; |
| | | if(m_nPointIndex >= m_nMemSize) |
| | | { |
| | | m_nPointIndex = 0; |
| | | } |
| | | |
| | | m_nPointNum++; |
| | | if(m_nPointNum >= m_nMemSize) |
| | | { |
| | | m_nPointNum = m_nMemSize; |
| | | } |
| | | |
| | | m_pPoints[m_nPointIndex] = point; |
| | | m_nPushCount++; |
| | | } |
| | | |
| | | template <typename T> |
| | | void CakQueueCircle<T>::setData( unsigned int nindex , T point ) |
| | | { |
| | | int pointindex = m_nPointIndex-nindex; |
| | | |
| | | if(pointindex<0) pointindex = m_nPointNum + pointindex; |
| | | |
| | | m_pPoints[pointindex] = point; |
| | | } |
| | | |
| | | template <typename T> |
| | | T& CakQueueCircle<T>::operator[]( unsigned int nindex ) |
| | | { |
| | | int pointindex = m_nPointIndex-nindex; |
| | | |
| | | if(pointindex<0) pointindex = m_nPointNum + pointindex; |
| | | |
| | | return m_pPoints[pointindex]; |
| | | } |
| | | |
| | | template <typename T> |
| | | CakQueueCircle<T>& CakQueueCircle<T>::operator=( CakQueueCircle<T>& queuecircle ) |
| | | { |
| | | if(m_nMemSize != queuecircle.m_nMemSize) |
| | | { |
| | | if(m_pPoints) |
| | | { |
| | | delete [] m_pPoints; |
| | | } |
| | | |
| | | m_pPoints = new T[queuecircle.m_nMemSize]; |
| | | } |
| | | |
| | | |
| | | m_nMemSize = queuecircle.m_nMemSize; |
| | | m_nPointIndex = queuecircle.m_nPointIndex; |
| | | m_nPointNum = queuecircle.m_nPointNum; |
| | | |
| | | memcpy(m_pPoints, queuecircle.m_pPoints, sizeof(T)*queuecircle.m_nMemSize); |
| | | |
| | | |
| | | |
| | | return *this; |
| | | } |