动态数组实现的双向队列,支持随机写读。
/*
DEQueue_array_dynamic.h
*/
#ifndef DEQUEUE_ARRAY_DYNAMIC_H
#define DEQUEUE_ARRAY_DYNAMIC_H
#include <iostream>
#include <iomanip>
#include <stdexcept>
using namespace std;
template<typename T>
class DEQueue_array_dynamic
{
private:
T *entry;
int head;
int rear;
int count;
int max_count;
public:
DEQueue_array_dynamic();
DEQueue_array_dynamic(const DEQueue_array_dynamic& deq);
~DEQueue_array_dynamic();
DEQueue_array_dynamic& operator = (const DEQueue_array_dynamic& deq);
void push_front(const T& item);
void pop_front();
void push_back(const T& item);
void pop_back();
bool empty() const;
void clear();
T front() const;
T back() const;
int size() const;
T& operator [] (int index) const;
void doublesize();
void display() const; // For teaching use
};
template<typename T>
DEQueue_array_dynamic<T>::DEQueue_array_dynamic()
{
max_count