Java implementation of heaps and priority queues