=====includes=====
Syntax:
#include
template< typename InIterA, typename InIterB >
bool includes( InIterA start1, InIterA end1, InIterB start2, InIterB end2 );
template< typename InIterA, typename InIterB, typename StrictWeakOrdering >
bool includes( InIterA start1, InIterA end1, InIterB start2, InIterB end2, StrictWeakOrdering cmp );
The includes() algorithm returns ''true'' if every element in [start2,end2) is also
in [start1,end1). Both of the given ranges must be sorted in ascending order. There is no requirement that every element in [start1,end1) or [start2,end2) be unique. If some element appears //n// times in [start2,end2), [start1,end1) must contain the equivalent element at least //n// times.
By default, the < operator is used to compare elements. If the strict weak
ordering function object cmp is given, then it is used instead.
includes() runs in [[/complexity|linear time]].
#include
#include
#include
#include
int main()
{
std::vector vec;
for (int i = 0; i < 10; ++i)
vec.push_back(i);
std::list lst;
lst.push_back(2);
lst.push_back(4);
lst.push_back(6);
if (std::includes(vec.begin(), vec.end(), lst.begin(), lst.end()))
std::cout << "lst is a subset of vec." << std::endl;
else
std::cout << "lst is NOT a subset of vec." << std::endl;
return 0;
}
Related Topics: [[set_difference]], [[set_intersection]], [[set_symmetric_difference]], [[set_union]]