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 04-03-2010
Member
 
Join Date: Dec 2009
Posts: 31
The includes() function of C++

I am studying in the MSC-IT. I can have learn the C++ language. I can know the concept of functions. I can learn the functions in the first semester of the BSC-IT in the C language. So, I would like to know about the includes() function of the C++ language. I also would like to know about what is the use of the includes() function of the C++ language. Anyone can help me to know about the includes() function of the C++ language, Reply Me!!!
Reply With Quote
  #2  
Old 04-03-2010
Member
 
Join Date: Apr 2008
Posts: 1,948
The includes() function

The includes() function of the C++ can be used to check whether range that can be sorted includes another range that can be sorted. The includes() function can returns the true value if all the elements that can be in the given range [fst2,lst2) can be similar to some element in the range [fst1,lst1). The following can be the general form of the includes() function in the C++ language as :
Code:
template <class InptItrtr1, class InptItrtr2>
  bool includes ( InptItrtr1 fst1, InptItrtr1 lst1,
                  InptItrtr2 fst2, InptItrtr2 lst2 );
Reply With Quote
  #3  
Old 04-03-2010
Member
 
Join Date: May 2008
Posts: 2,008
The includes() function of C++

The includes() function algorithm can returns the true value if each an element in the rang [strt2,nd2) can also be in the range [strt1,nd1). Both of the given specified ranges can must be arranges in an order of ascending. There can no requirement that each an element in the range [strt1,nd1) or in the range [strt2,nd2) can be unique. If some of an element can be appears n times in the range [strt2,nd2), [strt1,nd1) can must contain the similar element at least n times. The < operator can be used to compare an elements, By default.
Reply With Quote
  #4  
Old 04-03-2010
Member
 
Join Date: Apr 2008
Posts: 2,001
The includes() function of C++

The following program can demonstrates you that how to use the includes() function in the C++ programming language as follows :
Code:
#include <iostream>
#include <algorithm>
using namespace std;
bool myfunction (int p, int q) 
{ 
return p<q; 
}
int main ()
 {
  int cntnr[] = {5,10,15,20,25,30,35,40,45,50};
  int cntnt[] = {40,30,20,10};
  sort (cntnr,cntnr+10);
  sort (cntnt,cntnt+4);
  if ( includes(cntnr,cntnr+10,cntnt,cntnt+4) )
    cout << "cntnr includes cntnt!" << endl;
  if ( includes(cntnr,cntnr+10,cntnt,cntnt+4, myfunction) )
    cout << "cntnr includes cntnt!" << endl;
  return 0;
}
Output:
Code:
cntnr includes cntnt!
cntnr includes cntnt!
Reply With Quote
  #5  
Old 04-03-2010
Member
 
Join Date: May 2008
Posts: 2,293
Re: The includes() function of C++

The following can be the parameters of the includes() function of the C++ language as :
1. fst2, lst2 : These parameters of the includes() function can contains an input iterators to the final and starting positions of the given second sequence that can be checked on whether it can contained in the first sequence or not.
2. fst1, lst1 : These parameters of the includes() function can contains an input iterators to the final and starting positions of the given first sequence that can be checked on whether it can contains the second sequence or not.
Reply With Quote
  #6  
Old 04-03-2010
Member
 
Join Date: Nov 2005
Posts: 1,323
The includes() function of C++

The includes() function can runs in a linear time. Here can be the one more example that can help's you to learn the includes() function of the C++ language :
Code:
#include <iostream>
#include <vector>
#include <list>
#include <algorithm>
 int main()
{
std::vector<int> vc;
for (int a = 0; a < 10; ++a)
vc.push_back(a);
std::list<int> ls;
ls.push_back(3);
ls.push_back(4);
ls.push_back(5);
if (std::includes(vc.begin(), vc.end(), ls.begin(), ls.end()))
    std::cout << "ls is a subset of vc." << std::endl;
  else
    std::cout << "ls is NOT a subset of vc." << std::endl;
return 0;
}
Reply With Quote
Reply

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



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "The includes() function of C++"
Thread Thread Starter Forum Replies Last Post
Indie Royale's Summer Bundle for $5.44 includes 9 Games Addis Web News & Trends 1 02-07-2012 07:10 PM
Context menu in Windows7 includes removeproperties Sorah Operating Systems 6 31-05-2011 09:38 AM
How to Unlock Sony Ericsson to work on all networks, includes xperia 10 Artificial-Intelligent Portable Devices 5 15-02-2011 03:10 PM
What is SSI (server-side includes) and How should I use it? robin45 Windows Software 5 28-11-2009 05:18 PM
Xbox Live Avatars now includes Soccer shirts reddevil6 Video Games 2 22-07-2009 07:53 PM


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