All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
AStarPriorityQueue.h
1 #pragma once
2 
3 #include "Graphs.h"
4 #include "Types.h"
5 #include "AStarState.h"
6 
7 #include <queue>
8 
9 
10 namespace Eegeo
11 {
12  namespace Graphs
13  {
15  {
16  public:
17  AStarStatePriorityComparer(const std::vector<AStarState>& astarStateVector)
18  : m_astarStateVector(astarStateVector)
19  {}
20 
21  inline bool operator ()(const int ia, const int ib) const
22  {
23  const auto& a = m_astarStateVector.at(ia);
24  const auto& b = m_astarStateVector.at(ib);
25  return a.F() > b.F();
26  }
27  private:
28  const std::vector<AStarState>& m_astarStateVector;
29 
30  };
31 
33  {
34  using container_type = std::vector<int>;
36  using type = std::priority_queue<int, container_type, predicate_type>;
37  };
38 
39  class AStarPriorityQueue : public AStarPriorityQueueTraits::type, private Eegeo::NonCopyable
40  {
41  public:
43  : AStarPriorityQueueTraits::type(comparer)
44  {}
45 
46  void reorder()
47  {
48  std::make_heap(std::begin(c), std::end(c), comp);
49  }
50  };
51  }
52 }