diff src/parallel_execution/SingleLinkedQueue.cbc @ 590:9146d6017f18 default tip

hg mv parallel_execution/* ..
author anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
date Thu, 16 Jan 2020 15:12:06 +0900
parents a4cab67624f7
children
line wrap: on
line diff
--- a/src/parallel_execution/SingleLinkedQueue.cbc	Thu Jan 16 15:11:11 2020 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,68 +0,0 @@
-#include "../context.h"
-#include <stdio.h>
-#interface "Queue.h"
-// use "Node.h"
-// use "Element.h"
-
-Queue* createSingleLinkedQueue(struct Context* context) {
-    struct Queue* queue = new Queue();
-    struct SingleLinkedQueue* singleLinkedQueue = new SingleLinkedQueue();
-    queue->queue = (union Data*)singleLinkedQueue;
-    singleLinkedQueue->top  = new Element();
-    singleLinkedQueue->last = singleLinkedQueue->top;
-    queue->take  = C_takeSingleLinkedQueue;
-    queue->put  = C_putSingleLinkedQueue;
-    queue->isEmpty = C_isEmptySingleLinkedQueue;
-    queue->clear = C_clearSingleLinkedQueue;
-    return queue;
-}
-
-void printQueue1(union Data* data) {
-    struct Node* node = &data->Element.data->Node;
-    if (node == NULL) {
-        printf("NULL");
-    } else {
-        printf("key = %d ,", node->key);
-        printQueue1((union Data*)data->Element.next);
-    }
-}
-
-void printQueue(union Data* data) {
-    printQueue1(data);
-    printf("\n");
-}
-
-__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(...);
-}
-
-__code takeSingleLinkedQueue(struct SingleLinkedQueue* queue, __code next(union Data* data, ...)) {
-    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, ...);
-}
-
-__code isEmptySingleLinkedQueue(struct SingleLinkedQueue* queue, __code next(...), __code whenEmpty(...)) {
-    if (queue->top == queue->last) {
-        goto whenEmpty(...);
-    } else {
-        goto next(...);
-    }
-}
-