X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=src%2Fgduqueue.cpp;fp=src%2Fgduqueue.cpp;h=b0886cb6ce04a0114498df3b85b3f5b786e04c43;hb=b03c09ff93152fb9387281ad5431e6b4d44f16cd;hp=0000000000000000000000000000000000000000;hpb=594ba02c8c039a6570451da08e3461f22a7d0d11;p=yazpp-moved-to-github.git diff --git a/src/gduqueue.cpp b/src/gduqueue.cpp new file mode 100644 index 0000000..b0886cb --- /dev/null +++ b/src/gduqueue.cpp @@ -0,0 +1,66 @@ +/* + * Copyright (c) 1998-2005, Index Data. + * See the file LICENSE for details. + * + * $Id: gduqueue.cpp,v 1.1 2005-10-13 09:56:38 adam Exp $ + */ + +#include +#include + +using namespace yazpp_1; + +GDUQueue::GDUQueue() +{ + m_list = 0; +} + +int GDUQueue::size() +{ + int no = 0; + GDUQueue_List *l; + for (l = m_list; l; l = l->m_next) + no++; + return no; +} + +void GDUQueue::enqueue(GDU *gdu) +{ + GDUQueue_List *l = new GDUQueue_List; + l->m_next = m_list; + l->m_item = gdu; + m_list = l; +} + +GDU *GDUQueue::dequeue() +{ + GDUQueue_List **l = &m_list; + if (!*l) + return 0; + while ((*l)->m_next) + l = &(*l)->m_next; + GDU *m = (*l)->m_item; + delete *l; + *l = 0; + return m; +} + +void GDUQueue::clear() +{ + GDU *g; + while ((g = dequeue())) + delete g; +} + +GDUQueue::~GDUQueue() +{ + clear(); +} +/* + * Local variables: + * c-basic-offset: 4 + * indent-tabs-mode: nil + * End: + * vim: shiftwidth=4 tabstop=8 expandtab + */ +