//
// genq3.cpp - generic queue using void *
// elements and an iteration function
//
#include "genq3.h"
void genq::append(void *e)
{
cell *p = new cell(e, 0);
if (first == 0)
first = p;
else
last->next = p;
last = p;
}
void genq::clear()
{
cell *p;
while (first != 0)
{
p = first;
first = first->next;
delete p->element;
delete p;
}
last = 0;
}
void genq::apply(void f(void *))
{
cell *p;
for (p = first; p != 0; p = p->next)
f(p->element);
}
int genq::remove(void *&e)
{
if (first == 0)
return 0;
cell *p = first;
if ((first = first->next) == 0)
last = 0;
e = p->element;
delete p;
return 1;
}
// End of File