James Kanze
10/29/2008 9:36:00 AM
On Oct 28, 11:49 pm, Sam <s...@email-scan.com> wrote:
> silverburgh.me...@gmail.com writes:
> > Is there a STL algorithm to compare if 2 vector<int> have
> > same values?
> a.size() == b.size() && std::equal(a.begin(), a.end(), b.begin())
Which is exactly what a == b would do. And which tests if the
two vector have the same values IN THE SAME ORDER.
The simplest way to see if they have the same values is to sort
them first, then compare. For types other than int, though,
this may mean that you have to define a possibly arbitrary
ordering relationship.
--
James Kanze (GABI Software) email:james.kanze@gmail.com
Conseils en informatique orientée objet/
Beratung in objektorientierter Datenverarbeitung
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34