If I want to remove the highest entry in log(n)
time in Java's TreeSet
, I use treeSet.pollFirst()
- what is the equivalent for Scala's mutable.TreeSet
class?
Anyway, what I really want is a heap-like priority queue data structure that lets me removeMax
, add
and updatePriority
in logarithmic time. I looked at the Scala collections library and I am confused - while mutable.PriorityQueue
lets me deque
(i.e. removeMax
) in logarithmic time - it provides no way to update priority in log time (I would have to hackily scan and remove item and re-add in linear time). Similarly mutable.TreeSet
would let me update priority in logarithmic time (by hackily deleting and re-adding) but it does not have a removeMax
(i.e. pollFirst
) operation. What collections container should I use? Please do not refer me to external dependencies.