I'd add a `toArray` method in `BoundedPriorityQueue` instead of this, since it might be used elsewhere.