41 Queue() : buf(1), first(0), end(0) {}
43 void clear (
bool dealloc =
false) { buf.clear(dealloc); buf.growTo(1); first = end = 0; }
44 int size ()
const {
return (end >= first) ? end - first : end - first + buf.size(); }
49 T
peek ()
const {
assert(first != end);
return buf[first]; }
50 void pop () {
assert(first != end); first++;
if (first == buf.size()) first = 0; }
53 if (end == buf.size()) end = 0;
55 vec<T> tmp((buf.size()*3 + 1) >> 1);
58 for (j = first; j < buf.size(); j++) tmp[i++] = buf[j];
59 for (j = 0 ; j < end ; j++) tmp[i++] = buf[j];