MCPcopy Create free account
hub / github.com/Project-OSRM/osrm-backend / BinaryHeap

Class BinaryHeap

include/util/binary_heap.hpp:10–38  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

8
9// in its essence it is std::priority_queue, but with `clear` method
10template <typename T> class BinaryHeap
11{
12 public:
13 bool empty() const { return heap_.empty(); }
14
15 const T &top() const
16 {
17 BOOST_ASSERT(!heap_.empty());
18 return heap_.front();
19 }
20
21 void pop()
22 {
23 BOOST_ASSERT(!heap_.empty());
24 std::pop_heap(heap_.begin(), heap_.end());
25 heap_.pop_back();
26 }
27
28 template <typename... Args> void emplace(Args &&...args)
29 {
30 heap_.emplace_back(std::forward<Args>(args)...);
31 std::push_heap(heap_.begin(), heap_.end());
32 }
33
34 void clear() { heap_.clear(); }
35
36 private:
37 std::vector<T> heap_;
38};
39
40} // namespace osrm::util

Callers

nothing calls this directly

Calls 2

emptyMethod · 0.45
frontMethod · 0.45

Tested by

no test coverage detected