Comparing two vectors element by element
Hi: I need to compare two vectors. I already have a function to compare two individual elements (std::bitsets) in this case. Can I use boost.foreach to do this, or is there a better way. I need to know whether vector one, is less than vector two. Any help apreciated. Cheers Sean. __________ Information from ESET NOD32 Antivirus, version of virus signature database 3428 (20080909) __________ The message was checked by ESET NOD32 Antivirus. http://www.eset.com
Hi!
This is not a directly a boost question. The answer is below
On Tue, Sep 9, 2008 at 5:55 PM, Sean Farrow
Hi: I need to compare two vectors. I already have a function to compare two individual elements (std::bitsets) in this case. Can I use boost.foreach to do this, or is there a better way. I need to know whether vector one, is less than vector two.
STL defines different algorithms in <algorithm> header. There is an equal algorithm. In you case you can write: #include <vector> #include <algorithm> #include <functional> using namespace std; vector<int> v1; vector<int> v2; equal(v1.begin(), v1.end(), v2.begin(), less<int>()); This is how to compare 2 vector instances if one is less than the other. I do not really understand your question about bitsets. Do you have vector of bitsets? If so, replace int in vector template instantiation with your bitset instantiation and less<int>() with the instance to your functor. Hope that helps, Ovanes
participants (2)
-
Ovanes Markarian
-
Sean Farrow