Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read

Reply
 
Thread Tools Search this Thread
  #1  
Old 05-03-2010
Member
 
Join Date: Dec 2009
Posts: 26
How to use the pop_heap() in C++ coding

I am the student of the Bsc-CS. I must have to submit the assignment on the functions of the C++ library in four days. I could also had the well knowledge of the functions that could be used in the C++ programming language. Even though, I could not know much more about the pop_heap() function of the C++ programming language. So, I would like to know about the pop_heap() function of the C++ programming language. I also would like to know How to use the pop_heap() in C++ coding. Reply Me!!
Reply With Quote
  #2  
Old 05-03-2010
Member
 
Join Date: Apr 2008
Posts: 1,948
The pop_heap() in C++ coding

The pop_heap() function can be used for an element that can be from the given heap range to pop that an element. The pop_heap() function can re-sequence an elements in the given specified range [fst,lst) in such a manner that the some place of considered a heap can be narrowed by one by deleting its highest an element. The following can be the general syntax of the pop_heap() function in the C++ :
Code:
template <class RndmAcsItrtr>
  void pop_heap ( RndmAcsItrtr fst, RndmAcsItrtr lst );

Last edited by Praetor : 05-03-2010 at 05:12 PM.
Reply With Quote
  #3  
Old 05-03-2010
Member
 
Join Date: May 2008
Posts: 2,008
Use the pop_heap() in C++ coding

The program that can be mentioned below illustrates you about how to use the pop_heap() function in the C++ language programming :
Code:
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main () 
{
  int mit[] = {10,20,30,5,15};
  vector<int> w(mit,mit+5);
  vector<int>::iterator it;
  make_heap (w.begin(),w.end());
  cout << "initial max heap   : " << w.front() << endl;
  pop_heap (w.begin(),w.end()); w.pop_back();
  cout << "max heap after pop : " << w.front() << endl;
  w.push_back(99); push_heap (w.begin(),w.end());
  cout << "max heap after push: " << w.front() << endl;
  sort_heap (w.begin(),w.end());
  cout << "final sorted range :";
  for (unsigned k=0; k<w.size(); k++) cout << " " << w[k];
  cout << endl;
  return 0;
}
Output:
Code:
initial max heap   : 30
max heap after pop : 20
max heap after push: 99
final sorted range : 5 10 15 20 99
Reply With Quote
  #4  
Old 05-03-2010
Member
 
Join Date: Apr 2008
Posts: 2,001
How to use the pop_heap() in C++ coding

The following can be the parameters of the pop_heap() function of the C++ language :
1. comp : This parameter of the pop_heap() function can contains an object of the comparison function that can takes two values of the similar type than those can consisted in the given specified range.
2. fst, lst : These parameters of the pop_heap() function can contains the random-Access iterators to the final and starting positions of the heap that can be shrank by one. The range used can be as [fst,lst) that can contains all of an elements that can be between fst and lst.
Reply With Quote
  #5  
Old 05-03-2010
Member
 
Join Date: May 2008
Posts: 2,293
How to use the pop_heap()

The pop_heap() function of the C++ language can be used to delete the highest an element that can be defined as an element at the front of the heap from the specified heap. If an object of the weak sequencing comparison function can be given then it can be used instead of the "<" operator to compare an elements. The pop_heap() function can runs in a logarithmic time. The pop_heap() function of the C++ language can be comes under the <algorithm> header files.
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: , , , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "How to use the pop_heap() in C++ coding"
Thread Thread Starter Forum Replies Last Post
java coding unikshegz Software Development 1 27-10-2010 01:56 AM
Help me to use the transform() in C++ coding Tailor Software Development 5 19-02-2010 04:17 PM
Help in coding documents Remedy Software Development 5 11-02-2010 02:34 AM
C++ coding faster? Chandrakant81 Software Development 3 17-02-2009 10:51 PM
Problem with C coding SANDESH49 Software Development 2 02-09-2008 01:23 PM


All times are GMT +5.5. The time now is 06:41 PM.