Mercurial > hg > Papers > 2021 > soto-thesis
view paper/src/singleLinkedQueue.cbc @ 4:bf1f62556b81
add while_test_init_imple
author | soto |
---|---|
date | Thu, 11 Feb 2021 17:03:31 +0900 |
parents | 959f4b34d6f4 |
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(...); } .....