By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,460 Members | 1,436 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,460 IT Pros & Developers. It's quick & easy.

comparing two hashes (maps)

P: n/a
i have two hashes (maps)

map <int, int> FAULTFREENETS;
map <int, int> FAULTNETS;

is there a way i can check if FAULTFREENETS = FAULTNETS with just one
statement instead of writing a for loop with iterators, etc. ?

(just trying to reduce code clutter)

Nov 22 '05 #1
Share this Question
Share on Google+
6 Replies


P: n/a
mahur...@gmail.com wrote:
i have two hashes (maps)

map <int, int> FAULTFREENETS;
map <int, int> FAULTNETS;

is there a way i can check if FAULTFREENETS = FAULTNETS with just one
Don't use all-caps for variable names. Reserve that for macros.
statement instead of writing a for loop with iterators, etc. ?

(just trying to reduce code clutter)


Lookup std::equal() from <algorithm> or roll-up your own function and
call it.
Jonathan

Nov 22 '05 #2

P: n/a
ma******@gmail.com wrote:
i have two hashes (maps)

map <int, int> FAULTFREENETS;
map <int, int> FAULTNETS;

is there a way i can check if FAULTFREENETS = FAULTNETS with just one
statement instead of writing a for loop with iterators, etc. ?

(just trying to reduce code clutter)


Of course, the obvious works

if (FAULTFREENETS == FAULTNETS)
{
cout << "they're equal\n";
}

john
Nov 22 '05 #3

P: n/a
John Harrison wrote:
ma******@gmail.com wrote:
i have two hashes (maps)

map <int, int> FAULTFREENETS;
map <int, int> FAULTNETS;

is there a way i can check if FAULTFREENETS = FAULTNETS with just one
statement instead of writing a for loop with iterators, etc. ?

(just trying to reduce code clutter)


Of course, the obvious works

if (FAULTFREENETS == FAULTNETS)
{
cout << "they're equal\n";
}


I just hate when this happens.
Jonathan

Nov 22 '05 #4

P: n/a
perfectamundo. "=" works like a charm.

Nov 22 '05 #5

P: n/a
ma******@gmail.com wrote:
i have two hashes (maps)

map <int, int> FAULTFREENETS;
map <int, int> FAULTNETS;


If this is std::map, then just use operator ==. But they are not hash maps.

--

Valentin Samko - http://www.valentinsamko.com
Nov 22 '05 #6

P: n/a
ma******@gmail.com wrote:
perfectamundo. "=" works like a charm.


That should be ==, not =.
Jonathan

Nov 22 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.