1

プロパティ マップの値でソートされたヒープを維持しようとしています。以下のコードを試してみましたが、コンパイラはヒープ コンストラクター (PriorityQueueType pq(indirectComparison);) への引数を気に入りません。ドキュメント (http://www.boost.org/doc/libs/1_51_0/doc/html/boost/heap/binomial_heap.html) によると、コンストラクターがあります。

明示的な binomial_heap(value_compare const & = value_compare());

これは、私が提供したタイプ IndirectComparisonType になると考えていた value_compare を取ります (オプションのテンプレート引数と base_maker::compare_argument タイプのものを本当に理解していません)?

参照用の indirect_cmp ドキュメントは次のとおりです 。 http://www.boost.org/doc/libs/1_51_0/boost/pending/indirect_cmp.hpp

#include <boost/heap/binomial_heap.hpp>
#include <boost/pending/indirect_cmp.hpp>
#include <boost/array.hpp>
#include <boost/graph/grid_graph.hpp>
#include <iostream>

int main(int, char*[])
{
  // Construct a graph
  boost::array<std::size_t, 2> lengths = { { 2,2 } };
  typedef boost::grid_graph<2> GraphType;
  GraphType graph(lengths);
  typedef boost::graph_traits<GraphType>::vertex_descriptor Vertex;
  typedef boost::property_map<GraphType,
boost::vertex_index_t>::const_type GridIndexMapType;
  GridIndexMapType gridIndexMap(get(boost::vertex_index, graph));

  // Construct a property map
  typedef boost::vector_property_map<float, GridIndexMapType> PriorityMapType;
  PriorityMapType priorityMap(gridIndexMap);

  // Construct the indirect comparison functor
  typedef boost::indirect_cmp<PriorityMapType, std::less<float> >
IndirectComparisonType;
  IndirectComparisonType indirectComparison(priorityMap);

  // Construct the queue
  typedef int ValueType;
  typedef boost::heap::binomial_heap<ValueType,
boost::heap::stable<false>, IndirectComparisonType> PriorityQueueType;
  PriorityQueueType pq(indirectComparison);

  return 0;
}

この間接比較ファンクターをキューに適切に提供する方法を知っている人はいますか?

4

1 に答える 1

0

docsboost::heap::compareに示されているように、テンプレート オプションをそのように識別するために、で囲む必要があります。

于 2012-09-05T21:15:11.520 に答える