SDC C-Project CF Review 프로그램
LYW
2021-10-15 07a62310a7480610663ffc608491cf46370d99b8
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
#pragma once
 
 
#include "akSTLLinker.h"
#include <memory.h>
 
    class AKSTL_DLLSPEC CakQueue
    {
    public:
        CakQueue(void);
        ~CakQueue(void);
 
    public:
        bool empty()
        {    
            return m_nDataSize == 0 ? true : false;
        }
 
        size_t size()
        {
            return m_nDataSize;
        }
 
        char* front()
        {
            return &m_pQueue[m_stPoint];
        }
 
        char* back()
        {
            return &m_pQueue[m_stPoint+m_nDataSize-1];
        }
 
        void push(char _Val)
        {
            if(m_stPoint+m_nDataSize >= m_nMemSize)
            {
                size_t newsize = m_nMemSize*2;
                char* pNewQueue = new char [newsize];
                memcpy(pNewQueue, &m_pQueue[m_stPoint], sizeof(char)*(m_nMemSize-m_stPoint));
                m_nMemSize = newsize;
                m_stPoint = 0;
                char* pTemp = m_pQueue;
                m_pQueue = pNewQueue;
                delete [] pTemp;
 
            }
 
            
            m_pQueue[m_stPoint+m_nDataSize] = _Val;
            m_nDataSize++;
        }
 
        void push(char* pVal, int nSize)
        {
            if(m_stPoint+m_nDataSize + nSize >= m_nMemSize)
            {
                size_t newsize = m_nMemSize+nSize*2;
                char* pNewQueue = new char [newsize];
                memcpy(pNewQueue, &m_pQueue[m_stPoint], sizeof(char)*(m_nMemSize-m_stPoint));
                m_nMemSize = newsize;
                m_stPoint = 0;
                char* pTemp = m_pQueue;
                m_pQueue = pNewQueue;
                delete [] pTemp;
 
            }
 
            //m_enPoint++;
            memcpy(&m_pQueue[m_stPoint+m_nDataSize], pVal, sizeof(char)*nSize);
            m_nDataSize+=nSize;
        }
 
        void pop()
        {
            m_stPoint++;
            m_nDataSize--;
 
            if(m_nDataSize == 0)
            {
                m_stPoint=m_nDataSize=0;
            }
        }
        void pop(int nSize)
        {
            m_stPoint += nSize;
            m_nDataSize -= nSize;
            
            if(m_nDataSize == 0)
            {
                m_stPoint=m_nDataSize=0;
            }
        }
    private:
        size_t m_stPoint; //¸Þ¸ð¸® ½ÃÀÛÀ§Ä¡
        size_t m_nDataSize; //¸Þ¸ð¸® ³¡ À§Ä¡
        size_t m_nMemSize; //ÇÒ´çµÈ ¸Þ¸ð¸® »çÀÌÁî
        char*  m_pQueue;
        
    };