Click here to Skip to main content
15,896,207 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: error C2039 Pin
S. Senthil Kumar3-Jul-05 3:53
S. Senthil Kumar3-Jul-05 3:53 
GeneralRe: error C2039 Pin
John R. Shaw3-Jul-05 7:19
John R. Shaw3-Jul-05 7:19 
GeneralClassWizard Problem : Help Me Pin
prateekduble2-Jul-05 12:25
prateekduble2-Jul-05 12:25 
GeneralRe: ClassWizard Problem : Help Me Pin
John R. Shaw2-Jul-05 16:51
John R. Shaw2-Jul-05 16:51 
GeneralRe: ClassWizard Problem : Help Me Pin
prateekduble2-Jul-05 19:13
prateekduble2-Jul-05 19:13 
GeneralRe: ClassWizard Problem : Help Me Pin
John R. Shaw2-Jul-05 20:46
John R. Shaw2-Jul-05 20:46 
QuestionAnyone with Boost::Graph experience? Pin
Nathan Addy2-Jul-05 9:35
Nathan Addy2-Jul-05 9:35 
AnswerRe: Anyone with Boost::Graph experience? Pin
John R. Shaw2-Jul-05 18:03
John R. Shaw2-Jul-05 18:03 
A rough guess:
map1[0,1] = ?
map1[0,2] = ?
...

map2[0,1] = ?
map2[0,2] = ?
...

join(map1,map2);

new_map1[0,1] = ?
new_map1[0,2] = ?
...

Possible Solution:
void shift_keys(map_type& map, map_type::size_type amt)
{
    // create new map with adjusted keys
    map_type new_map(map);
    map_type::iterator mi = map.begin();
    for( ; mi != map.end(); ++mi )
       new_map[std:make_pair((mi->first).first+amt,(mi->first).second+amt)]
           = mi->second;
    map.swap(new_map);
}
vod join(map_type& map1,map_type& map2)
{
    map_type new_map(map2)
    shift_keys(map2,map1.size());
    // join new_map to map1
    map_type::iterator mi = new_map.begin();
    for( ; mi != new_map.end(); ++mi )
       map1[mi->first] = mi->second;
}


This is an incomplete solution (off the top of my head). It should successfully join the two maps.

Example:
join(map1,map2);
map1[0,1] = ?
map1[0,2] = ?
..
map1[2,3] = ?
map1[2,4] = ?
...

I hope that helps you figure out the problem. Maps allow only one entry per-key; therefore, you have to change any key values in map2 that may be the same as a key values in map1 before you attempt to join them.

It may be more complicated than that, but I have essentially used simular code to join two maps.

INTP
"The more help VB provides VB programmers, the more miserable your life as a C++ programmer becomes."
Andrew W. Troelsen
GeneralDynamic Buttons Pin
Ger Hayden2-Jul-05 8:53
Ger Hayden2-Jul-05 8:53 
GeneralRe: Dynamic Buttons Pin
PJ Arends2-Jul-05 9:30
professionalPJ Arends2-Jul-05 9:30 
QuestionBlinking Button? Pin
DanYELL2-Jul-05 6:30
DanYELL2-Jul-05 6:30 
AnswerRe: Blinking Button? Pin
Trollslayer2-Jul-05 6:49
mentorTrollslayer2-Jul-05 6:49 
AnswerRe: Blinking Button? Pin
toxcct2-Jul-05 7:20
toxcct2-Jul-05 7:20 
AnswerRe: Blinking Button? Pin
Michael Dunn3-Jul-05 10:26
sitebuilderMichael Dunn3-Jul-05 10:26 
QuestionTCHAR error? Pin
Larsson2-Jul-05 6:09
Larsson2-Jul-05 6:09 
AnswerRe: TCHAR error? Pin
PJ Arends2-Jul-05 9:38
professionalPJ Arends2-Jul-05 9:38 
AnswerRe: TCHAR error? Pin
Tom Archer2-Jul-05 9:39
Tom Archer2-Jul-05 9:39 
AnswerRe: TCHAR error? Pin
John R. Shaw2-Jul-05 18:19
John R. Shaw2-Jul-05 18:19 
GeneralThreading Pin
Umair Ahmad khan2-Jul-05 0:53
Umair Ahmad khan2-Jul-05 0:53 
GeneralRe: Threading Pin
Umair Ahmad khan2-Jul-05 1:02
Umair Ahmad khan2-Jul-05 1:02 
GeneralRe: Threading Pin
meinhard_risch2-Jul-05 6:59
meinhard_risch2-Jul-05 6:59 
GeneralRe: Threading Pin
Umair Ahmad khan2-Jul-05 10:41
Umair Ahmad khan2-Jul-05 10:41 
GeneralRe: Threading Pin
David Crow2-Jul-05 12:12
David Crow2-Jul-05 12:12 
Questionhow to read the header row in excel file? Pin
qqworm2-Jul-05 0:37
qqworm2-Jul-05 0:37 
GeneralFolder Synchronization Pin
M.Mehrdad.M1-Jul-05 22:47
M.Mehrdad.M1-Jul-05 22:47 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.