SDC C-Project CF Review 프로그램
LYW
2021-07-23 a6552335164ce062567b76aa7d097fd046129474
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
#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;
    }