#include "context.h" #include #impl "Queue.h" as "SingleLinkedQueue.h" #data "Node.h" #data "Element.h" Queue* createSingleLinkedQueue(struct Context* context) { struct Queue* queue = new Queue(); struct SingleLinkedQueue* singleLinkedQueue = new SingleLinkedQueue(); queue->queue = (union Data*)singleLinkedQueue; queue->take = C_takeSingleLinkedQueue; queue->put = C_putSingleLinkedQueue; queue->isEmpty = C_isEmptySingleLinkedQueue; queue->clear = C_clearSingleLinkedQueue; singleLinkedQueue->top = new Element(); singleLinkedQueue->last = singleLinkedQueue->top; return queue; } // ~~省略~~ __code takeSingleLinkedQueue(struct SingleLinkedQueue* queue, __code next(union Data* data, ...)) { printf("take\n"); struct Element* top = queue->top; struct Element* nextElement = top->next; if (queue->top == queue->last) { data = NULL; } else { queue->top = nextElement; data = nextElement->data; } goto next(data, ...); } // ~~省略~~