Alternative implementation of a priority queue