is_heap_until

Returns an iterator positioned at the first element in the range [begin, end) that does not satisfy the heap ordering condition, or end if the range forms a heap.

template<class RandomAccessIterator>
    RandomAccessIterator is_heap_until(
        RandomAccessIterator begin, 
        RandomAccessIterator end
    );
template<class RandomAccessIterator, class BinaryPredicate> 
    RandomAccessIterator is_heap_until(
        RandomAccessIterator begin, 
        RandomAccessIterator end, 
        BinaryPredicate compare
    );

Parameters

  • begin
    A random access iterator that specifies the first element of a range to check for a heap.

  • end
    A random access iterator that specifies the end of the range to check for a heap.

  • compare
    A binary predicate that specifies the strict weak ordering condition that defines a heap. The default predicate when compare is not specified is std::less<>.

Return Value

Returns end if the specified range forms a heap or contains one or fewer elements. Otherwise, returns an iterator for the first element found that does not satisfy the heap condition.

Remarks

The first template function returns the last iterator next in [begin, end] where [begin, next) is a heap ordered by the function object std::less<>. If the distance end - begin < 2, the function returns end.

The second template function behaves the same as the first, except that it uses the predicate compare instead of std::less<> as the heap ordering condition.

Requirements

Header: <algorithm>

Namespace: std

See Also

Reference

is_heap

less Struct

<algorithm>

Standard Template Library