-2

could anyone please tell me how to write this priority queue (written in C++) using Java

priority_queue< pair< int, Hole >, vector< pair< int, Hole > >, Hole::CompH > moves;

the CompH is a struct:

   struct CompH {
                bool operator()(const pair< int, Hole >& lhs, const pair< int, Hole >& rhs) const
                {
                        return lhs.second.getH() < rhs.second.getH();
                }
        };

I want to understand this part so I can write it in Java, Please. Thanks

nanofarad
  • 40,330
  • 4
  • 86
  • 117
Mido_007
  • 19
  • 2

1 Answers1

0

The CompH is directly analogous to a java.util.Comparator, and the PQ class itself is java.util.PriorityQueue.

user207421
  • 305,947
  • 44
  • 307
  • 483