MCPcopy Create free account
hub / github.com/Shannon-Data/ShannonBase / heapify

Method heapify

include/priority_queue.h:136–159  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

134 }
135
136 void heapify(size_type i, size_type last) {
137 assert(i < size());
138 size_type largest = i;
139
140 do {
141 i = largest;
142 size_type l = left(i);
143 size_type r = right(i);
144
145 if (l < last && Base::operator()(m_container[i], m_container[l])) {
146 largest = l;
147 }
148
149 if (r < last && Base::operator()(m_container[largest], m_container[r])) {
150 largest = r;
151 }
152
153 if (largest != i) {
154 std::swap(m_container[i], m_container[largest]);
155 m_marker(i, &m_container[i]);
156 m_marker(largest, &m_container[largest]);
157 }
158 } while (largest != i);
159 }
160
161 void heapify(size_type i) { heapify(i, m_container.size()); }
162

Callers

nothing calls this directly

Calls 7

assertClass · 0.85
swapFunction · 0.70
sizeMethod · 0.65
sizeClass · 0.50
leftFunction · 0.50
rightFunction · 0.50
operator()Function · 0.50

Tested by

no test coverage detected