I am trying to keep a heap sorted by values in a property map. I tried
the code below, but the compiler does not like my arguments to the
heap constructor (PriorityQueueType pq(indirectComparison);).
According to the documentation
(http://www.boost.org/doc/libs/1_51_0/doc/html/boost/heap/binomial_heap.html),
there is a constructor:
explicit binomial_heap(value_compare const & = value_compare());
that takes a value_compare, which I was thinking would of type
IndirectComparisonType that I provided (I don't really understand the
optional template arguments and the base_maker::compare_argument type
of things)?
Here is the indirect_cmp doc for reference:
http://www.boost.org/doc/libs/1_51_0/boost/pending/indirect_cmp.hpp
#include
#include
#include
#include
#include <iostream>
int main(int, char*[])
{
// Construct a graph
boost::array lengths = { { 2,2 } };
typedef boost::grid_graph<2> GraphType;
GraphType graph(lengths);
typedef boost::graph_traits<GraphType>::vertex_descriptor Vertex;
typedef boost::property_map::const_type GridIndexMapType;
GridIndexMapType gridIndexMap(get(boost::vertex_index, graph));
// Construct a property map
typedef boost::vector_property_map PriorityMapType;
PriorityMapType priorityMap(gridIndexMap);
// Construct the indirect comparison functor
typedef boost::indirect_cmp
IndirectComparisonType;
IndirectComparisonType indirectComparison(priorityMap);
// Construct the queue
typedef int ValueType;
typedef boost::heap::binomial_heap PriorityQueueType;
PriorityQueueType pq(indirectComparison);
return 0;
}
Does anyone know how to provide this indirect comparison functor to
the queue properly?
Thanks,
David