

 Thread Tools  Search this Thread 
#1
 
 
Use of the push_heap() function in the C++ I like to do the the programming .in C++ language. I had learned the C++ language in the BSCIT. I can know the actual concept or working of the C++ functions. So, I want to know what is the push_heap() function of the C++ language. I also want to know what is the use of the push_heap() function in the C++ programming. Can anyone knows about the push_heap() function of C++ language. 
#2
 
 
The push_heap() function in the C++ The push_heap() function of the C++ language can be used to add an element that can be defined as the end element before end into a heap that can be defined as the range of an elements that can be in between the range [strt,''end1). If an object of the weak sequencing comparison function that can be given then it can be used in place of the "<" operator to compare an elements. The push_heap() function can be executed in logarithmic time.
__________________ Grand Theft Auto 4 PC Video Game 
#3
 
 
push_heap() function in the C++ The push_heap() function can given a heap range such as [fst,lst1), the push_heap() function that can extends the range that can be considered a heap to the range [fst,lst) by placing the value in (lst1) in its relevant place in it. The following can be the syntax of the push_heap() function in C++ language : Code: template <class RndmAcesItrtr> void push_heap ( RndmAcesItrtr fst, RndmAcesItrtr lst );
__________________ The FIFA Manager 2009 PC Game 
#4
 
 
Use of th push_heap() function in the C++ I can suggest you that to carefully go through the following code of lines that can demonstrates you how to use the push_heap() function in the C++ programming as follows : Code: #include <iostream> #include <algorithm> #include <vector> using namespace std; int main () { int mit[] = {10,20,30,5,15}; vector<int> z(mit,mit+5); vector<int>::iterator it; make_heap (z.begin(), z.end()); cout << "initial max heap : " << z.front() << endl; pop_heap (z.begin(), z.end()); z.pop_back(); cout << "max heap after pop : " << z.front() << endl; z.push_back(99); push_heap (z.begin(), z.end()); cout << "max heap after push: " << z.front() << endl; sort_heap (z.begin(),z.end()); cout << "final sorted range :"; for (unsigned j=0; j<z.size(); j++) cout << " " << z[j]; cout << endl; return 0; } Code: initial max heap : 30 max heap after pop : 20 max heap after push: 99 final sorted range : 5 10 15 20 99 
#5
 
 
re: Use of the push_heap() function in the C++ The following can be the general syntax of the push_heap() function in the C++ language : 1. cmp : This parameters of the push_heap() function can contains an object of the comparison function that can taking two values of the similar type than those that can contained in the given range. 2. fst, lst : These parameters of the push_heap() function can contains the random access iterators to the final and starting positions of the newer heap including an element that can be pushed. The range used can be as [fst,lst). 
#6
 
 
The push_heap() function Here can be the one more example on the push_heap() function of the C++ language and the following program can help's you to learn the push_heap() function : Code: #include <iostream> #include <vector> #include <list> #include <algorithm> #include <functional> #include <numeric> template <class S> inline void PRNTELMNTS (const S& cl, const char* otcstr="") { typename S::const_iterator pos; std::cout << otcstr; for (p=cl.begin(); p!=cl.end(); ++p) { std::cout << *p << ' '; } std::cout << std::endl; } template <class S> inline void INSRTELMNTS (S& cl, int fst, int lst) { for (int a=fst; a<=lst; ++a) { cl.insert(cl.end(),a); } } using namespace std; int main() { vector<int> cl; INSRTELMNTS(cl,3,7); INSRTELMNTS(cl,5,9); INSRTELMNTS(cl,1,4); PRNTELMNTS (cl, "on entry: "); cl.push_back (17); push_heap (cl.begin(), cl.end()); PRNTELMNTS (cl, "after push_heap(): "); } Code: on entry: 3 4 5 6 7 5 6 7 8 9 1 2 3 4 after push_heap(): 17 8 9 7 7 5 6 3 6 4 1 2 3 4 5 

Tags: algorithm, cpp, functions, header files, push_heap 
Thread Tools  Search this Thread 

Similar Threads for: "Use of the push_heap() function in the C++"  
Thread  Thread Starter  Forum  Replies  Last Post 
c++ equivalent function to the cfunction 'sprintf  Dilbert  Software Development  6  13122011 04:03 PM 
c# function equivalent to gettime function in javascript  Omaar  Software Development  4  10032010 10:44 PM 
How to pass function with parameters to another function in PHP?  Linoo  Software Development  5  27022010 07:52 PM 
How does abstract function differs from virtual function?  Maddox G  Software Development  5  29012010 11:32 AM 
Function keys don't function under windows XP  GunFighter  Hardware Peripherals  3  08042009 11:07 PM 