/*
* call-seq:
* pq.pop -> elem
*
* Returns the top element in the queue removing it from the queue.
*/
static VALUE
frt_pq_pop(VALUE self)
{
PriQ *pq;
GET_PQ(pq, self);
if (pq->size > 0) {
VALUE result = pq->heap[1]; /* save first value */
pq->heap[1] = pq->heap[pq->size]; /* move last to first */
pq->heap[pq->size] = Qnil;
pq->size--;
pq_down(pq); /* adjust heap */
return result;
}
else {
return Qnil;
}
}