| 279 | } |
| 280 | |
| 281 | inline int HeapList::HeapDelete(HeapEntry* item) |
| 282 | { |
| 283 | if (HeapEmpty()) { |
| 284 | return -1; |
| 285 | } |
| 286 | |
| 287 | int pos = item->GetIndex() ; |
| 288 | if ((pos > _count) ||(pos <= 0)) |
| 289 | { |
| 290 | heap_assert(0); // duplicated deletion or illegal data. |
| 291 | return -2; |
| 292 | } |
| 293 | |
| 294 | HeapEntry* del = _list[pos]; |
| 295 | _list[pos] = _list[_count]; |
| 296 | _list[pos]->SetIndex(pos); |
| 297 | |
| 298 | _list[_count] = 0; |
| 299 | _count--; |
| 300 | |
| 301 | HeapDown(pos); |
| 302 | heap_assert(pos == del->GetIndex()); |
| 303 | del->SetIndex(0); |
| 304 | return 0; |
| 305 | } |
| 306 | |
| 307 | |
| 308 | inline void HeapList::HeapForeach() |
no test coverage detected