Mercurial > hg > Papers > 2023 > soto-master
view Paper/src/singleLinkedQueue.cbc @ 32:4915eaa51ee0 default tip
Add front
author | soto <soto@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Thu, 23 Feb 2023 18:39:56 +0900 |
parents | a72446879486 |
children |
line wrap: on
line source
#interface "Queue.h" Queue* createSingleLinkedQueue(struct Context* context) { struct Queue* queue = new Queue(); // Allocate Queue interface struct SingleLinkedQueue* singleLinkedQueue = new SingleLinkedQueue(); // Allocate Queue implement queue->queue = (union Data*)singleLinkedQueue; singleLinkedQueue->top = new Element(); singleLinkedQueue->last = singleLinkedQueue->top; queue->clear = C_clearSingleLinkedQueue; queue->put = C_putSingleLinkedQueue; queue->take = C_takeSingleLinkedQueue; queue->isEmpty = C_isEmptySingleLinkedQueue; return queue; } __code clearSingleLinkedQueue(struct SingleLinkedQueue* queue, __code next(...)) { queue->top = NULL; goto next(...); } __code putSingleLinkedQueue(struct SingleLinkedQueue* queue, union Data* data, __code next(...)) { Element* element = new Element(); element->data = data; element->next = NULL; queue->last->next = element; queue->last = element; goto next(...); } .....