Sign in to follow this  
zedzeek

stl::subset

Recommended Posts

im wanting to find if a set of numbers is a subset of another set im pretty sure stl would have an equivilant algorithm but its doesnt seem to (unless ive missed it) the closest match i see is includes(...) but this has the added requirement that the sets need to be sorted ie the following example will return false A[] = {1,4,5,8,2}; B[] = {2,4,8}; includes( A.begin(),A.end(),B.begin(),B.end() ); ta zed

Share this post


Link to post
Share on other sites
What container are you using? If you use a std::set, then they'll already be ordered, thus, no problem.

Share this post


Link to post
Share on other sites
sorry im using std::vector<int>
thanks for the info about set though (i didnt know that) i may use it (though ild prefer not to change)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this