Comparator for min-heap in C++
问题 I am trying to make a min-heap 1 of long s in C++ using the STL make_heap , etc., but my comparator doesn't seem to be comparing properly. The following is my current comparator: struct greater1{ bool operator()(const long& a,const long& b) const{ return a>b; } }; However, when I do std::pop_heap(humble.begin(),humble.end(),g); where g is an instance of greater1 and humble is a heap who makes [9,15,15,25] when sort_heap is called, I get a 15 popped. Is my comparator correct? what might be