/*
* call-seq:
* pq.insert(elem) -> self
* pq << elem -> self
*
* Insert an element into a queue. It will be inserted into the correct
* position in the queue according to its priority.
*/
static VALUE
frt_pq_insert(VALUE self, VALUE elem)
{
PriQ *pq;
GET_PQ(pq, self);
if (pq->size < pq->capa) {
pq_push(pq, elem);
}
else if (pq->size > 0 && frt_pq_lt(pq->proc, pq->heap[1], elem)) {
pq->heap[1] = elem;
pq_down(pq);
}
/* else ignore the element */
return self;
}