473,406 Members | 2,217 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

STL algorithm to compare if 2 vector<int> have same value?

Hi,

Is there a STL algorithm to compare if 2 vector<inthave same values?

Thank you.
Oct 28 '08 #1
3 4321
Sam
si***************@gmail.com writes:
Hi,

Is there a STL algorithm to compare if 2 vector<inthave same values?
a.size() == b.size() && std::equal(a.begin(), a.end(), b.begin())

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)

iEYEABECAAYFAkkHlwwACgkQx9p3GYHlUOIVwACeM4BAlohvf9 h3c9cLANS+PV4Y
U8MAmwftvYXPjKXZtqqtyD3Lw/xN3a8M
=7d8M
-----END PGP SIGNATURE-----

Oct 28 '08 #2
si***************@gmail.com wrote:
Is there a STL algorithm to compare if 2 vector<inthave same values?
std::equal() is probably the function you are looking for.
Oct 28 '08 #3
si***************@gmail.com wrote:
Hi,

Is there a STL algorithm to compare if 2 vector<inthave same values?
Assuming

vector<inta;
vector<intb;

and some code that fills them, what is wrong with

a == b
Best

Kai-Uwe Bux
Oct 28 '08 #4

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

Similar topics

3
by: Erik Borgstr?m | last post by:
Hi, Yes, I have followed some of the discussion on vector<vector<int> >, but perhaps I'm just blind. I want to use a vector<vector<int> > of outer size n and inner size m. Are these correct ways...
1
by: Alex Vinokur | last post by:
------ foo.cpp ------ #include <vector> using namespace std; int main() { const vector<int> v1 (10); const vector<bool> v2 (10); &v1;
20
by: Anonymous | last post by:
Is there a non-brute force method of doing this? transform() looked likely but had no predefined function object. std::vector<double> src; std::vector<int> dest; ...
6
by: Roman Töngi | last post by:
I want to change a vector in a function. I pass a pointer of it to the function and append an item. Then I want to print the first item in the vector. It doesn't work. Can anyone help me? Thanks...
5
by: pmatos | last post by:
Hi all, I have a vector of vector of ints, I could use C approach by using int but I think C++ vector<vector<int> > would be easier to manage. So I have a function which creates and initializes...
10
by: Piotr | last post by:
I have a class 'Statistics' which has a private attribute ' vector<int>* _x;' And in the destructor of the Statistics, I have this code to free the memory: Statistics::~Statistics() { if...
4
by: arnuld | last post by:
i wrote a programme to create a vector of 5 elements (0 to 4), here is the code & output: #include <iostream> #include <vector> int main() { std::vector<intivec; // dynamically create a...
2
by: danielhdez14142 | last post by:
Some time ago, I had a segment of code like vector<vector<int example; f(example); and inside f, I defined vector<int>'s and used push_back to get them inside example. I got a segmentation...
0
by: citystud | last post by:
does C# support vector< vector<int> > ?if not how can i use vector?
1
by: jrusse39 | last post by:
I am attempting to access the last member of the a vector which is the second part of the pair<string, vector<int>>. The following code snippet shows what I am attempting: typedef...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.