diff options
Diffstat (limited to 'src/prioq.c')
-rw-r--r-- | src/prioq.c | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/src/prioq.c b/src/prioq.c index 9559d31..7cd29e8 100644 --- a/src/prioq.c +++ b/src/prioq.c @@ -1,18 +1,19 @@ +#include "prioq.h" + #include "alloc.h" #include "genalloc.h" -#include "prioq.h" -GEN_ALLOC_readyplus(prioq,struct prioq_elt,p,len,a,i,n,x,100,prioq_readyplus) +GEN_ALLOC_readyplus(prioq, struct prioq_elt, p, len, a, i, n, x, 100, prioq_readyplus) -int prioq_insert(prioq *pq, struct prioq_elt *pe) + int prioq_insert(prioq *pq, struct prioq_elt *pe) { int i; int j; - if (!prioq_readyplus(pq,1)) return 0; + if (!prioq_readyplus(pq, 1)) return 0; j = pq->len++; while (j) { - i = (j - 1)/2; + i = (j - 1) / 2; if (pq->p[i].dt <= pe->dt) break; pq->p[j] = pq->p[i]; j = i; @@ -49,6 +50,6 @@ void prioq_delmin(prioq *pq) pq->p[i] = pq->p[j]; i = j; } - pq->p[i] = pq->p[n]; - pq->len = n; + pq->p[i] = pq->p[n]; + pq->len = n; } |