is_heap_until() in C++

is_heap_until(): This function is available in the file stl_heap.h. This function is used to searches the end of a heap. This function returns an iterator pointing to the first element, not in the heap.

Parameters: Two parameters are required for this function.

 __first – Start of range. 

__last – End of range. 

Syntax:

vector<data_type>::iterator it = is_heap_until(__first,__last)

For Example:

arr = { 7,3,4,1,2,10}

it = is_heap_until(arr.begin(),arr.end()) = > It returns the iterator pointing to 10 ( because 10 is the first element in the range not in the heap)

Approach

C++

#include <bits/stdc++.h>
using namespace std;

int main()
{
    vector<intarr = {7341210};

    vector<int>::iterator it = is_heap_until(arr.begin(), 
arr.end());

    cout << *it << "\n";

    return 0;
}


No comments:

Post a Comment