The first complete implementation for priority queue.