| 195 | |
| 196 | |
| 197 | inline void HeapList::HeapDown(int index) |
| 198 | { |
| 199 | int min_son; |
| 200 | for (int pos = index; pos <= _count; pos = min_son) |
| 201 | { |
| 202 | if (pos*2 > _count) // pos is a leaf node. |
| 203 | { |
| 204 | break; |
| 205 | } |
| 206 | else if (pos*2 == _count) |
| 207 | { |
| 208 | min_son = pos*2; |
| 209 | } |
| 210 | else |
| 211 | { |
| 212 | if (_list[pos*2+1]->HeapValueCmp(_list[pos*2]) < 0) |
| 213 | { |
| 214 | min_son = pos*2+1; |
| 215 | } |
| 216 | else |
| 217 | { |
| 218 | min_son = pos*2; |
| 219 | } |
| 220 | } |
| 221 | |
| 222 | if (_list[pos]->HeapValueCmp(_list[min_son]) > 0) |
| 223 | { |
| 224 | HeapEntry* tmp = _list[min_son]; |
| 225 | _list[min_son] = _list[pos]; |
| 226 | _list[pos] = tmp; |
| 227 | |
| 228 | _list[pos]->SetIndex(pos); |
| 229 | _list[min_son]->SetIndex(min_son); |
| 230 | } |
| 231 | else |
| 232 | { |
| 233 | break; |
| 234 | } |
| 235 | } |
| 236 | } |
| 237 | |
| 238 | |
| 239 | inline int HeapList::HeapPush(HeapEntry* item) |
nothing calls this directly
no test coverage detected