

 Thread Tools  Search this Thread 
#1
 
 
Implement the set_intersection() in C++ I am working in the MNC company as software programmer. We can use the C++ programming language for developing the software at my work place. Thus, I could not know much more about the set_intersection() function of the C++ language. So, I would like to know about the set_intersection() function of the C++ programming language. I also would like to know about how to implement the set_intersection() function of the C++ programming language. Can anyone has the answer for me then reply me. I am waiting for your reply!!! 
#2
 
 
The set_intersection() in C++ The set_intersection() function algorithm can computes the intersection of the given two sets that can be defined by range [strt1,nd1) and the range [strt2,nd2) and The set_intersection() function can stores the intersection beginning at result. Both the sets, can be given as ranges that can must be sorted in an ascending order. The set_intersection() function can returns value of an iterator that can be to the end of the intersection range. The set_intersection() function can runs in a linear time. 
#3
 
 
Implement the set_intersection() in C++ The following program can demonstrates you how to implement the set_intersection() function of the C++ language in the C++ programming as follows : Code: #include <algorithm> #include <vector> #include <iostream> using namespace std; int main () { int fs[] = {5,1,35,2,45}; int sd[] = {5,4,3,2,1}; vector<int> r(10); vector<int>::iterator c; sort (fs,fs+5); sort (sd,sd+5); c=set_intersection (fs, fs+5, sd, sd+5, r.begin()); cout << "intersection has " << int(c  r.begin()) << " elements.\n"; return 0; } Code: intersection has 2 elements 
#4
 
 
set_intersection() in C++ The set_intersection() function can be used to constructs a range that can be sorted starting in the place that can be pointed by result with the given set of intersection of the two ranges [fst1,lst1) and range [fst2,lst2) that can be sorted as content. The intersection of two given sets can be formed only by the elements that can represent in both of the sets at the same time. The following can be the syntax of the set_intersection() function in the C++ language as follows : Code: template <class InptItrtr1, class InptItrtr2, class OtptItrtr> OtptItrtr set_intersection ( InptItrtr1 first1, InptItrtr1 last1, InptItrtr2 first2, InptItrtr2 last2, OtptItrtr result ); 
#5
 
 
Re: Implement the set_intersection() in C++ The following can be the parameters of the set_intersection() function of the C++ language as : 1. fst2, lst2 : These parameters of the set_intersection() function can contains an input iterators to the final and starting positions of the given second sequence. The range used can be as [fst2,lst2). 2. fst1, lst1 : These parameters of the set_intersection() function can contains an input iterators to the final and starting positions of the given first sequence. The range used can be as [fst1,lst1) that can contains all of an elements between fst1 and lst1 including an element that can be pointed by fst1 but not an element that can be pointed by lst1. 
#6
 
 
Re: Implement the set_intersection() in C++ The code that can be mentioned below also states you about the working of the set_intersection() function of the C++ language : Code: #include <iostream> #include <cassert> #include <algorithm> #include <vector> using namespace std; int main() { bool result; string h("abcde"); string h2("aeiou"); vector<char> vt1(h.begin(), h.end()); vector<char> vt2(h2.begin(), h2.end()); vector<char> setIntersection; set_intersection(vt1.begin(), vt1.end(),vt2.begin(), vt2.end(), back_inserter(setIntersection)); for(int g=0; g<setIntersection.size(); g++) { cout << setIntersection[g]; } return 0; }
__________________ Grand Theft Auto 4 PC Video Game 

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

Similar Threads for: "Implement the set_intersection() in C++"  
Thread  Thread Starter  Forum  Replies  Last Post 
How to implement sum() faster in c#?  LuisFernando  Software Development  4  27022010 09:25 PM 
How can I implement the remove() in CPP  Servant  Software Development  5  22022010 04:18 PM 
Implement the copy_backward() in C++  Agustíne  Software Development  5  16022010 09:46 PM 
How to implement IP Sec  Enriquee  Technology & Internet  5  12012010 06:28 AM 
Want to implement differentiation in C++  ADEN  Software Development  1  25102008 06:13 PM 