473,490 Members | 2,737 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

regarding the usage of set_difference with maps

i am using maps with a string in the template argument and i want to
find the difference of two maps into another amp for this i can use the
set_difference function but the arguments of the functions are
iterators.
can any one help me in this how to send the arguments in
to the function.

Thanks in advance.

Regards
Dilip

May 22 '06 #1
3 3626
sd*******@gmail.com wrote:
i am using maps with a string in the template argument and i want to
find the difference of two maps into another amp for this i can use the
set_difference function but the arguments of the functions are
iterators.
can any one help me in this how to send the arguments in
to the function.

set_difference( first.begin(), first.end(),
second.begin(), second.end(),
result.begin() );

--
Ian Collins.
May 22 '06 #2
this is the same i have done but i am getting an std:pair error asking
some operator should be over loaded . for this i am attaching the code
which i have used.....
#include <map>
#include <algorithm>
#include <functional> // For greater<int>( )
#include <iostream>
#include<vector>

using namespace std;

int main( )
{

map<char*,int> mapobj1;
map<char*,int> mapobj2;
map<char*,int> mapobj3;

mapobj1["one"] = 111;
mapobj1["two"] = 112;
mapobj1["three"] = 113;
mapobj1["four"] = 114;

mapobj2["five"] = 111;
mapobj2["two"] = 112;
mapobj2["three"] = 113;
mapobj2["four"] = 124;

set_difference(mapobj1.begin(),mapobj1.end(),mapob j2.begin(),mapobj2.end(),mapobj3.begin());
}
and the error is
error C2582: 'std::pair<char * const,int>' : 'operator =' function is
unavailable

May 22 '06 #3
Ian Collins wrote:
sd*******@gmail.com wrote:
i am using maps with a string in the template argument and i want to
find the difference of two maps into another amp for this i can use the
set_difference function but the arguments of the functions are
iterators.
can any one help me in this how to send the arguments in
to the function.


set_difference( first.begin(), first.end(),
second.begin(), second.end(),
result.begin() );


set_difference(first.begin(), first.end(),
second.begin(), second.end(),
back_inserter(result), pred);

where pred takes two pair objects and compares them appropriately. Since
result is a map, you can't overwrite its values, so you need back_inserter.

--

Pete Becker
Roundhouse Consulting, Ltd.
May 22 '06 #4

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

Similar topics

8
5206
by: Mike | last post by:
Hello, I have a few rather urgent questions that I hope someone can help with (I need to figure this out prior to a meeting tomorrow.) First, a bit of background: The company I work for is...
3
60990
by: Sean | last post by:
Have you ever wanted to add the great features inherent in Google Maps? Here is how you do it. ============== == STEP ONE == ============== Create a new MS Access form called frmGoogleMap....
72
3400
by: Robin Tucker | last post by:
I need to find some documents/research for my manager about VB.NET v C# use. I've noticed that there are many more people using C# than VB.NET, that there seem to be more job vacancies specifying...
1
1886
by: KK | last post by:
Hi, I'm trying to come up with an efficient way to solve the following problem. Let A = { (1, b), (2, d), (3, a), (4, c) ,... } B = { (1, d), (2, a), (3, e), (4, f),... } where a,b,c......
8
3880
by: sam_cit | last post by:
Hi, I came to read this particular statement with respect to reducing the complexity of a code, The usage of functional maps matrices instead of switch statements should be considered. I...
3
8714
by: tezheng | last post by:
since std::map is some kind of std::set<std::pair> can i use "set_difference" with std::map? how to deal with the "operator =" of std::pair<T1, T2>, as T1 and T2 could be various type.
1
997
by: Duncan Smith | last post by:
Just before I have to implement my own.. I don't suppose the .NET framework has an equivalent of the STL set_difference algorithm yet...? For e.g. If I have two containers: CompareSet={1,2,3}...
3
2210
by: mahaveer | last post by:
Hi , I am facing a strange problem with STL maps ,I am using gdb to debug my debug my code. Upto one point the number of entries in the map is shown as follows , $79 = {_M_t = { _M_impl...
19
3281
by: Ganesh J. Acharya | last post by:
Hi there, I want to redesign my website and make that look professional. I made this about 6 years ago with very little knowledge of internet. Today I am getting about 4000 visitors a day for...
0
6974
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
7146
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,...
1
6852
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
7356
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...
1
4878
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4573
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3084
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3074
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
277
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.