开发者

priority queue insertion

开发者 https://www.devze.com 2023-03-10 02:47 出处:网络
Im working on a method for insertion into priority queue using the huffman method. However I keep getting the same error:

Im working on a method for insertion into priority queue using the huffman method. However I keep getting the same error:

     prioque.c:46: error: expected ")" before "prioque_ref"

my structures are:

typedef struct prioque *prioque_ref;
struct prioque {
    int dim;
    int last;
    prioque_item *array开发者_JAVA技巧;
    cmpfn_prioque cmpfn;
};

my code in question:

void insert_prioque (prioque prioque_ref *queue, prioque_item item) {
    assert ( queue->last < queue->dim -1);

    ++queue->last;
    queue->array[queue->last] = item;
    int curr = last;

    while (curr != ROOT) {
        int parent = PARENT(curr);
        int *parentptr = &queue->array[parent];
        int *curptr = &queue->array[curr];

        if (*parentptr > *currptr)
            break;

        int tmp = *currptr;
        *currptr = *parentptr;
        *parentptr = tmp;
        curr = parent;
    }

    DEBUGF ('p', "queue=%p, item=%p\n", queue, item);
}

What am i doing wrong here??


You have already done a typedef for prioque *

void insert_prioque (prioque prioque_ref *queue, prioque_item item)
                         // ^ complaining about this space

So, it should be -

void insert_prioque (prioque_ref queue, prioque_item item) { /* .... */ }
0

精彩评论

暂无评论...
验证码 换一张
取 消