/*
- * Copyright (C) 1995-2008 University of Karlsruhe. All right reserved.
+ * Copyright (C) 1995-2011 University of Karlsruhe. All right reserved.
*
* This file is part of libFirm.
*
* @param q The priority queue.
* @return The length of the queue.
*/
-FIRM_API int pqueue_length(const pqueue_t *q);
+FIRM_API size_t pqueue_length(const pqueue_t *q);
/**
* Returns true if queue is empty.
/*
- * Copyright (C) 1995-2008 University of Karlsruhe. All right reserved.
+ * Copyright (C) 1995-2011 University of Karlsruhe. All right reserved.
*
* This file is part of libFirm.
*
* Enforces the heap characteristics if the queue
* starting from element at position @p pos.
*/
-static void pqueue_heapify(pqueue_t *q, unsigned pos)
+static void pqueue_heapify(pqueue_t *q, size_t pos)
{
- unsigned len = ARR_LEN(q->elems);
+ size_t len = ARR_LEN(q->elems);
while (pos * 2 < len) {
pqueue_el_t tmp;
- unsigned exchange = pos;
+ size_t exchange = pos;
if (q->elems[exchange].priority < q->elems[pos * 2].priority) {
exchange = pos * 2;
/**
* Sifts up a newly inserted element at position @p pos.
*/
-static void pqueue_sift_up(pqueue_t *q, unsigned pos)
+static void pqueue_sift_up(pqueue_t *q, size_t pos)
{
while (q->elems[pos].priority > q->elems[pos / 2].priority) {
pqueue_el_t tmp;
ARR_SHRINKLEN(q->elems, 0);
return q->elems[0].data;
default: {
- void *data = q->elems[0].data;
- int len = ARR_LEN(q->elems) - 1;
+ void *data = q->elems[0].data;
+ size_t len = ARR_LEN(q->elems) - 1;
q->elems[0] = q->elems[len];
ARR_SHRINKLEN(q->elems, len);
}
}
-int pqueue_length(const pqueue_t *q)
+size_t pqueue_length(const pqueue_t *q)
{
return ARR_LEN(q->elems);
}