21 #ifndef ELM_DATA_LISTQUEUE_H_
22 #define ELM_DATA_LISTQUEUE_H_
24 #include <elm/assert.h>
25 #include <elm/data/Manager.h>
29 template <
class T,
class M = EquivManager<T> >
34 inline Node(
const T& v, Node *n = 0): next(n), val(v) { }
37 void *
operator new(
size_t s, M& m) {
return m.alloc.allocate(s); }
38 inline void free(M& m) { this->~Node(); m.alloc.free(
this); }
40 inline ~Node(
void) { }
47 inline bool isEmpty(
void)
const {
return !h; }
48 inline const T &
head(
void)
const { ASSERTP(h,
"empty queue");
return h->val; }
50 { ASSERTP(h,
"empty queue"); T r = h->val; Node *n = h; h = h->next;
if(!h) t = 0; n->free(_man);
return r; }
52 {
for(Node *n = h; n; n = n->next)
if(_man.eq.equals(n->val, val))
return true;
return false; }
54 inline void put(
const T &item)
55 { Node *n =
new(_man) Node(item); (h ? t->next : h) = n; t = n; }
57 {
for(Node *n = h, *nn; n; n = nn) { nn = n->next; n->free(_man); } }