You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@lucene.apache.org by oramas martín <jl...@gmail.com> on 2006/04/17 17:30:29 UTC

Reordering elements in a PriorityQueue

Hi all,

I would like to insert elements in a PriorityQueue where the value returned
by the 'lessThan' method for the same both objects can change over the time.
Just to clarify my problem, I would like to insert PriorityQueue objects in
the main PriorityQueue, so the 'lessThan' method from the main queue will
compare the top objects of the inserted priority queues.

So I would like to reorder an alement already in the queue, each time it is
detected a change in its value. AFAIK, it can not be done with the current
PriorityQueue implementation, so I have, apparently, two ways of doing it,
one can be remove the affected element and reinsert it, and the other is to
implement a reorder method. In either case I have to implement a new method,
but my understanding of the queue implementation is too low to decide what
of them is a better approach. ¿Can somebody points me in the right
direccion, explaining a bit how the queue works (upHeap and downHeap) or how
to implement the methods I need?

Thanks for your help,
José.