.\" ident @(#)includes.3 .\" Standard Template Library .\" $$RW_INSERT_HEADER "slyrs.man" .TH includes 3C++ "02 Apr 1998" "Rogue Wave Software" "-" .ce2 Standard C++ Library Copyright 1998, Rogue Wave Software, Inc. .SH NAME \f2includes\fP \ - A basic set of operation for sorted sequences. .SH SYNOPSIS .br #include .br template .br bool includes (InputIterator1 first1, InputIterator1 last1, .RE .RS 15 InputIterator2 first2, .br InputIterator2 last2); .RE .RS 0 .br template .RE .RS 0 bool includes (InputIterator1 first1, InputIterator1 last1, .RE .RS 13 InputIterator2 first2, .br InputIterator2 last2, Compare comp); .SH DESCRIPTION The includes algorithm compares two sorted sequences and returns \f2true\fP if every element in the range \f2[first2, last2)\fP is contained in the range \f2[first1, last1)\fP. It returns \f2false\fP otherwise. include assumes that the sequences are sorted using the less than operator (\f2operator<\fP), unless an alternative comparison operator (\f2comp\fP) is included. .SH COMPLEXITY At most \f2((last1 - first1) + (last2 - first2)) * 2 -1\fP comparisons are performed. .SH EXAMPLE .RE .RS 0 // .br // includes.cpp .br // .RE .RS 1 #include .br #include .br #include .RE .RS 0 using namespace std; .br .br int main() .RE .RS 1 { .RE .RS 0 .RE .RS 3 //Initialize some sets .RE .RS 2 int a1[10] = {1,2,3,4,5,6,7,8,9,10}; .br int a2[6] = {2,4,6,8,10,12}; .br int a3[4] = {3,5,7,8}; .br set > all(a1, a1+10), even(a2, a2+6), .RE .RS 24 small(a3,a3+4); .RE .RS 0 .RE .RS 2 //Demonstrate includes .RE .RS 1 cout << "The set: "; .br copy(all.begin(),all.end(), .RE .RS 7 ostream_iterator(cout," ")); .RE .RS 1 bool answer = includes(all.begin(), all.end(), .RE .RS 15 small.begin(), small.end()); .RE .RS 1 cout << endl .RE .RS 7 << (answer ? "INCLUDES " : "DOES NOT INCLUDE "); .RE .RS 1 copy(small.begin(),small.end(), .RE .RS 7 ostream_iterator(cout," ")); .RE .RS 1 answer = includes(all.begin(), all.end(), .RE .RS 19 even.begin(), even.end()); .RE .RS 1 cout << ", and" << endl .RE .RS 7 << (answer ? "INCLUDES" : "DOES NOT INCLUDE "); .RE .RS 1 copy(even.begin(),even.end(), .RE .RS 7 ostream_iterator(cout," ")); .RE .RS 1 cout << endl << endl; .RE .RS 0 .RE .RS 1 return 0; .br } .br .RE .RS 0 Program Output .RE .RS 0 .br The set: 1 2 3 4 5 6 7 8 9 10 .br INCLUDES 3 5 7 8 , and .br DOES NOT INCLUDE 2 4 6 8 10 12 .SH WARNINGS If your compiler does not support default template parameters, then you always need to supply the \f2Allocator\fP template argument. For instance, you have to write: \f2set, allocator >\fP instead of: \f2set\fP If your compiler does not support namespaces, then you do not need the using declaration for \f2std\fP. .SH SEE ALSO set,_set_union,_set_intersection, set_difference, set_symmetric_difference