21 #ifndef ELM_DATA_LISTQUEUE_H_
22 #define ELM_DATA_LISTQUEUE_H_
24 #include <elm/assert.h>
25 #include <elm/inhstruct/SLList.h>
29 template <
class T,
class E = Equiv<T> >
32 typedef struct node_t {
33 inline node_t(
const T& v, node_t *n = 0): next(n), val(v) { }
42 inline bool isEmpty(
void)
const {
return !h; }
43 inline const T &
head(
void)
const { ASSERTP(h,
"empty queue");
return h->val; }
45 { ASSERTP(h,
"empty queue"); T r = h->val; node_t *n = h; h = h->next;
if(!h) t = 0;
delete n;
return r; }
47 inline void put(
const T &item)
48 { node_t *n =
new node_t(item); (h ? t->next : h) = n; t = n; }
50 {
for(node_t *n = h, *nn; n; n = nn) { nn = n->next;
delete n; } }
const T & head(void) const
Definition: ListQueue.h:43
ListQueue & operator<<(const T &v)
Definition: ListQueue.h:52
bool isEmpty(void) const
Definition: ListQueue.h:42
~ListQueue(void)
Definition: ListQueue.h:40
void reset(void)
Definition: ListQueue.h:49
void put(const T &item)
Definition: ListQueue.h:47
ListQueue(void)
Definition: ListQueue.h:39
Definition: ListQueue.h:30
ListQueue & operator>>(T &v)
Definition: ListQueue.h:53