472,990 Members | 3,567 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,990 software developers and data experts.

STL - an algorithm for finding a collection within a collection?

Is there an STL algorithm that will return true if each element in
coll1 is present in coll2
Jul 23 '05 #1
5 1099
Dylan wrote:
Is there an STL algorithm that will return true if each element in
coll1 is present in coll2


I don't know of one specifically for this, but if this was the case,
the result from set_difference would be empty (this requires both
collections to be sorted).

--
Later,
Jerry.

The universe is a figment of its own imagination.

Jul 23 '05 #2
Dylan wrote:
Is there an STL algorithm that will return true if each element in
coll1 is present in coll2

If you want to check if the sequences are exactly the same, use std::equal.
--
Ioannis Vranos

http://www23.brinkster.com/noicys
Jul 23 '05 #3
Dylan wrote:
Is there an STL algorithm that will return true if each element in
coll1 is present in coll2


I think this requires sorted elements. I would use the std::mismatch()
algorithm. With the pair of iterators it returns you can tell if the containers
have equal contents or if one is a subset of the other.

--
Paul M. Dubuc
Jul 23 '05 #4
Dylan <sp******@ontheball.com> wrote in message news:<gp********************************@4ax.com>. ..
Is there an STL algorithm that will return true if each element in
coll1 is present in coll2


Look at:
http://www.sgi.com/tech/stl/includes.html

kwijibo
Jul 23 '05 #5
In article <gp********************************@4ax.com>,
Dylan <sp******@ontheball.com> wrote:
Is there an STL algorithm that will return true if each element in
coll1 is present in coll2


template <class InputIterator1, class InputIterator2>
bool includes(InputIterator1 first1, InputIterator1 last1,
InputIterator2 first2, InputIterator2 last2);

template <class InputIterator1, class InputIterator2,
class StrictWeakOrdering>
bool includes(InputIterator1 first1, InputIterator1 last1,
InputIterator2 first2, InputIterator2 last2,
StrictWeakOrdering comp);

Includes tests whether one sorted range includes another sorted range.
That is, it returns true if and only if, for every element in [first2,
last2), an equivalent element [1] is also present in [first1, last1)
[2]. Both [first1, last1) and [first2, last2) must be sorted in
ascending order.
Jul 23 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: m sergei | last post by:
I am not asking for code but wanted help with understanding the algorithm to permute all characters of a string. say string is "ABCD" I want to know the algorithm for finding all permutations of...
32
by: someone else | last post by:
hi all I'm a newbie to this group. my apologies if I break any rules. I've wrote a simple program to find the first 1,000,000 primes, and to find all primes within any range (up to 200 *...
3
by: Rob | last post by:
You can find datagrid in page by refering the form. Gatagrid is a child control of Form. Here is the code ----------------- Dim ctl As New Control For Each ctl In...
16
by: a | last post by:
We are writing an app that assigns people to teams based on their curent score. Teams are 8 people, there are 2 teams. (i would like it to be flexible, but this is a start). I need an algorithm...
2
by: The One We Call 'Dave' | last post by:
I have a list of DateTime objects stored in a collection: SortedList<DateTime,Object> MyDates=new SortedList<DateTime,Object>(); The dates, which can be accessed via MyDates.Keys, are stored in...
1
by: JP | last post by:
I have images within a datalist control. Below is a checkbox control that contains the SQL ID of the image blob. When the page is post back I want to iterate though checkbox collection to get...
2
by: premgrps | last post by:
Hi, I have a database with two tables a) A table of 2 million records with city, zip and associated information (say XYZ) and b) zipcode latitude, longitude table having >40,000 records/zip...
4
prometheuzz
by: prometheuzz | last post by:
Hello (Java) enthusiasts, In this article Id like to tell you a little bit about graphs and how you can search a graph using the BFS (breadth first search) algorithm. Ill address, and...
0
by: Chris M. Thomasson | last post by:
"Dmitriy V'jukov" <dvyukov@gmail.comwrote in message news:51a36d85-2fc6-4bd6-af64-29950ce5ab6a@59g2000hsb.googlegroups.com... Have you testing the following algorithm yet? ...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
3
SueHopson
by: SueHopson | last post by:
Hi All, I'm trying to create a single code (run off a button that calls the Private Sub) for our parts list report that will allow the user to filter by either/both PartVendor and PartType. On...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.