template <typename _T>
class CArrayQueue {
public:
    CArrayQueue() {
        m_rear = 0;
        m_front = 0;
        m_array = new _T[m_num];
    }
    bool full() const
    {
        return ((m_rear+1) % m_num == m_front);
    }
    bool empty() const
    {
        return (m_front == m_rear);
    }
    void push(const _T& t) {
        array[m_rear] = t;
        m_rear = (m_rear+1) % m_num;
    }
    _T& pop() {
        _T& t= array[m_front];
        m_front = (m_front+1) % m_num;
        return t;
    }
private:
    _T* array;
    int m_rear;
    int m_front;
};


阅读(838) | 评论(1) | 转发(0) |

热门推荐