Go to the documentation of this file.
15 #ifndef INCLUDE_VECQUEUE_HH_
16 #define INCLUDE_VECQUEUE_HH_
34 class vecQueue :
public Queue<T>
200 : _maxSize(initSize), _data(new value_type[initSize]), _rear(0)
237 return _data[_rear - 1];
243 return _data[_rear - 1];
249 if (_rear == _maxSize)
252 _data[_rear++] = val;
258 if (_rear == _maxSize)
261 _data[_rear++] = std::move(val);
269 _data[i] = _data[i + 1];
275 value_type *old = _data;
276 _data =
new value_type[_maxSize = 2 * _maxSize + 1];
size_type size() const
Returns the number of elements in the queue.
virtual value_type getHead() const
Get the Head object.
virtual value_type deQueue()
出队一个元素
virtual bool isEmpty() const
判队空
virtual void enQueue(const_reference &x)
入队一个元素
reference & front()
Returns a reference to the next element in the queue.
virtual ~vecQueue()
Destroy the vec Queue object.
value_type & reference
数据的引用
const typedef value_type & const_reference
数据的常量引用
reference & back()
Returns a reference to the last element in the queue.
void pop()
Removes the next element in the queue.
value_type * _data
存储队列的动态数组
自定义的队列类都在Queue名字空间下(linkQueue.hh)
value_type & reference
数据的引用
bool empty() const
Test whether container is empty.
size_type _maxSize
内部数组的规模
void push(const value_type &val)
Inserts a new element at the end of the queue, after its current last element.
vecQueue(size_type initSize=10)
Construct a new vec Queue object.