下面是乙個迴圈佇列的完整實現,歡迎讀者朋友參考和指正:
template
class cyclicqueue
~cyclicqueue()
cyclicqueue(const cyclicqueue& copy) : m_poppos(0), m_count(0)
}cyclicqueue& operator=(const cyclicqueue& other)
return (*this);
}bool is_empty() const
bool is_full() const
value_type front()
value_type front() const
value_type back()
value_type back() const
bool push(const_reference data = t())
return false;
}bool pop(reference data)
return false;
}size_type size() const
size_type capacity() const
void clear() // this->_clear();
void swap(cyclicqueue& other)
private:
void _clear()
m_poppos = 0;
}void _destroy(size_type idx)
void _copy(size_type idx, const_reference data)
void _swap(cyclicqueue& other)
value_type _back() const
value_type *m_beginptr; // 佇列儲存空間起始位置
size_type m_poppos; // 下次pop位置
size_type m_count; // 有效元素個數
};
如何實現乙個迴圈佇列
template class cyclicqueue cyclicqueue cyclicqueue const cyclicqueue copy m poppos 0 m count 0 cyclicqueue operator const cyclicqueue other return thi...
如何實現乙個迴圈佇列
template class cyclicqueue cyclicqueue cyclicqueue const cyclicqueue copy m poppos 0 m count 0 cyclicqueue operator const cyclicqueue other return thi...
如何實現乙個迴圈佇列
template class cyclicqueue cyclicqueue cyclicqueue const cyclicqueue copy m poppos 0 m count 0 cyclicqueue operator const cyclicqueue other return thi...