compare m_nodes[idx] with parent node.
| 434 | |
| 435 | // compare m_nodes[idx] with parent node. |
| 436 | bool up(int idx) |
| 437 | { |
| 438 | assert(!q.empty()); |
| 439 | auto tmp = q[idx]; |
| 440 | bool ret = false; |
| 441 | while (idx != 0){ |
| 442 | auto cmpIdx = (idx - 1) >> 1; |
| 443 | if (*tmp < *q[cmpIdx]) { |
| 444 | update_node(idx, q[cmpIdx]); |
| 445 | idx = cmpIdx; |
| 446 | ret = true; |
| 447 | continue; |
| 448 | } |
| 449 | break; |
| 450 | } |
| 451 | if (ret) update_node(idx, tmp); |
| 452 | return ret; |
| 453 | } |
| 454 | |
| 455 | // compare m_nodes[idx] with child node. |
| 456 | bool down(int idx) |