16 using diff_t =
typename std::iterator_traits<Iterator>::difference_type;
17 using elem_t =
typename std::iterator_traits<Iterator>::value_type;
20 diff_t count = std::distance(inBegin, inEnd);
23 diff_t current = count - 1;
27 elem_t ¤t_elem = *(inBegin + current);
30 diff_t parent = (current - 1) >> 1;
31 elem_t &parent_elem = *(inBegin + parent);
34 if (inPred(parent_elem, current_elem))
36 std::swap(parent_elem, current_elem);
54 using diff_t =
typename std::iterator_traits<Iterator>::difference_type;
57 std::swap(*(inEnd - 1), *inBegin);
60 diff_t count = std::distance(inBegin, inEnd) - 1;
67 diff_t child = (largest << 1) + 1;
74 diff_t prev_largest = largest;
77 if (inPred(*(inBegin + largest), *(inBegin + child)))
84 if (child < count && inPred(*(inBegin + largest), *(inBegin + child)))
88 if (prev_largest == largest)
92 std::swap(*(inBegin + prev_largest), *(inBegin + largest));
void BinaryHeapPop(Iterator inBegin, Iterator inEnd, Pred inPred)
Definition BinaryHeap.h:52
JPH_NAMESPACE_BEGIN void BinaryHeapPush(Iterator inBegin, Iterator inEnd, Pred inPred)
Definition BinaryHeap.h:14