优先队列插入
我正在研究一种使用霍夫曼方法插入优先级队列的方法。但是我不断收到相同的错误:
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);
}
我在这里做错了什么?
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;
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??
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您已经为
prioque *
完成了 typedef所以,它应该是 -
You have already done a typedef for
prioque *
So, it should be -