Results 1 to 6 of 6

Thread: The includes() function of C++

  1. #1
    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!!!

  2. #2
    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 );

  3. #3
    Join Date
    May 2008
    Posts
    2,012

    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.

  4. #4
    Join Date
    Apr 2008
    Posts
    2,005

    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!

  5. #5
    Join Date
    May 2008
    Posts
    2,297

    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.

  6. #6
    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;
    }

Similar Threads

  1. Indie Royale's Summer Bundle for $5.44 includes 9 Games
    By Addis in forum Web News & Trends
    Replies: 1
    Last Post: 02-07-2012, 07:10 PM
  2. Context menu in Windows7 includes removeproperties
    By Sorah in forum Operating Systems
    Replies: 6
    Last Post: 31-05-2011, 09:38 AM
  3. How to Unlock Sony Ericsson to work on all networks, includes xperia 10
    By Artificial-Intelligent in forum Portable Devices
    Replies: 5
    Last Post: 15-02-2011, 03:10 PM
  4. Replies: 5
    Last Post: 28-11-2009, 05:18 PM
  5. Xbox Live Avatars now includes Soccer shirts
    By reddevil6 in forum Video Games
    Replies: 2
    Last Post: 22-07-2009, 07:53 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,710,834,237.88459 seconds with 16 queries