PriorityQueueMonoid

46 views
Skip to first unread message

Koert Kuipers

unread,
Nov 16, 2013, 12:34:21 PM11/16/13
to alge...@googlegroups.com
In PriorityQueueMonoid there is a build method that takes an iterable:
def build(items: Iterable[K]): PriorityQueue[K]

Inside this method it creates the like this:
val q = new PriorityQueue(items.size max MINQUEUESIZE, ord.reverse);

Why base the size of the queue on the size of items if the queue can only grow to size max (or technically size max + 1 since it can first add one item before limiting it's size to max)?
If i have a very large iterable this leads to allocation a lot of memory for the queue which doesn't seem necessary to me.

Also if the queue was allocated like this
val q = new PriorityQueue(max + 1, ord.reverse);
then we could take an iterator instead of an iterable...


Reply all
Reply to author
Forward
0 new messages