MCPcopy Create free account
hub / github.com/HelenOS/helenos / priority_queue_iterator

Class priority_queue_iterator

uspace/lib/cpp/src/__bits/test/adaptors.cpp:44–102  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

42 {
43 template<class T, class Comp = std::less<T>>
44 class priority_queue_iterator
45 {
46 public:
47 using value_type = T;
48 using reference = const T&;
49 using size_type = size_t;
50 using pointer = value_type*;
51 using difference_type = size_t;
52
53 using iterator_category = forward_iterator_tag;
54
55 priority_queue_iterator(
56 priority_queue<value_type, std::vector<value_type>, Comp> q,
57 bool end = false
58 )
59 : queue_{q}, end_{end}
60 { /* DUMMY BODY */ }
61
62 priority_queue_iterator(const priority_queue_iterator& other)
63 : queue_{other.queue_}, end_{other.end_}
64 { /* DUMMY BODY */ }
65
66 reference operator*()
67 {
68 return queue_.top();
69 }
70
71 priority_queue_iterator& operator++()
72 {
73 queue_.pop();
74
75 if (queue_.empty())
76 end_ = true;
77
78 return *this;
79 }
80
81 priority_queue_iterator operator++(int)
82 {
83 auto old = *this;
84 ++(*this);
85
86 return old;
87 }
88
89 bool operator==(const priority_queue_iterator& rhs) const
90 {
91 return end_ == rhs.end_;
92 }
93
94 bool operator!=(const priority_queue_iterator& rhs) const
95 {
96 return !(*this == rhs);
97 }
98
99 private:
100 priority_queue<value_type, std::vector<value_type>, Comp> queue_;
101 bool end_;

Callers

nothing calls this directly

Calls 2

popMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected