循环队列

#include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; #define NULL 0 template class Queue { public: Queue(unsigned capacity):cap(capacity),_size(0),head(0),tail(-1) { v.resize(capacity); } bool empty() { return _size==0; } unsigned size() { return _size; } unsigned capacity() { return cap; } void push(const T& val) { assert(_size v; unsigned _size; int head; int tail; unsigned cap; }; int main() { srand(time(0)); const int capacity=100; Queue Myq(capacity); queue q; for (int i=0;i<10000;i++) { if (rand()%2) { if (Myq.size() Myq.tail) //{ // cout << "*******"; //} cout << endl; } assert(Myq.size()==q.size()); // return 0; }

你可能感兴趣的:(循环队列)