Recently, I found Boost.Heap very useful in my project. But I could not find any example code showing how I can set up arbitrary compare function.
#include "boost/heap/fibonacci_heap.hpp"
using boost::heap::fibonacci_heap;
int main(){
fibonacci_heap<int> pq; //default compare function std::less<int>
}
For example, how can I set std::greater< int >?
The boost.heap document says that it can be set by setting an option. But I don't know what it means. Can anyone help?
Try this:
typedef boost::heap::fibonacci_heap<
int,
boost::heap::compare<std::greater<int> > > MyHeap;
The documentation does not show how to specify options. I had to dig through the unit test source code to find out the correct usage syntax.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With