版权声明:欢迎读者提问交流。 个人水平有限,表述不当或疏漏之处敬请批评指正。 作者:trialley 来源:CSDN 著作权归作者所有。非商业转载请注明出处,商业转载请联系作者获得授权。 https://blog.csdn.net/lgfx21/article/details/89298067
具有push,pop,empty,front函数,跟STL queue兼容
template<class T>
struct queue {
int l = 0;
int r = 0;
T a [ 100000 ] ;
void push(T x) {
a[r] = x;
r=r+1;
}
T front() {
return a[l];
}
void pop() {
if(l<r){
l++;
return true;
}
else return false
}
bool empty() {
if (l == r)
return true;
return false;
}
};