вставка приоритетной очереди - PullRequest
0 голосов
/ 04 июня 2011

Я работаю над методом для вставки в приоритетную очередь, используя метод Хаффмана. Однако я продолжаю получать ту же ошибку:

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

мои структуры:

typedef struct prioque *prioque_ref;
struct prioque {
    int dim;
    int last;
    prioque_item *array;
    cmpfn_prioque cmpfn;
};

мой код под вопросом:

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);
}

Что я здесь не так делаю ??

1 Ответ

4 голосов
/ 04 июня 2011

Вы уже сделали typedef для prioque *

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

Итак, это должно быть -

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