Click here to Skip to main content
15,892,059 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: implementation of a key value array (not using std::map) ? Pin
doug256-Dec-09 14:20
doug256-Dec-09 14:20 
GeneralRe: implementation of a key value array (not using std::map) ? Pin
Stuart Dootson6-Dec-09 14:37
professionalStuart Dootson6-Dec-09 14:37 
GeneralRe: implementation of a key value array (not using std::map) ? Pin
doug256-Dec-09 15:07
doug256-Dec-09 15:07 
GeneralRe: implementation of a key value array (not using std::map) ? Pin
Stuart Dootson7-Dec-09 22:57
professionalStuart Dootson7-Dec-09 22:57 
GeneralRe: implementation of a key value array (not using std::map) ? Pin
doug258-Dec-09 3:07
doug258-Dec-09 3:07 
GeneralRe: implementation of a key value array (not using std::map) ? Pin
Stuart Dootson8-Dec-09 5:59
professionalStuart Dootson8-Dec-09 5:59 
GeneralRe: implementation of a key value array (not using std::map) ? Pin
doug258-Dec-09 17:01
doug258-Dec-09 17:01 
Questionre: probelms erasing a multimap entry Pin
Alan Kurlansky2-Dec-09 9:54
Alan Kurlansky2-Dec-09 9:54 
This program runs fine except when I try to delete/remove/erase an item as indicated below. No matter what I've tried with erasethe program crashes.
Could someone please help here.
Thanks
Alan Kurlansky

PS. When I cut and pasted some characters got changed. I hope I fixed alll of them.

// MultiMap.cpp : Defines the entry point for the console application.
//


#include <windows.h>
#include <stdio.h>
#include <iostream>
#include <string>
#include <map>
using namespace std;

void testmultimap();
#include <tchar.h>


struct ASK {
          int ival;
          string     key;
};

     multimap<string, ASK *> mymm2;
     multimap<string, ASK *>::iterator iter;
     pair<multimap<string, ASK> ::iterator,multimap<string, ASK *>::iterator> ret;

int _tmain(int argc, _TCHAR* argv[])
{
     testmultimap();
    
     return 0;
}

//----------------------------------------------------------------------------------------------------------------
void testmultimap()
{    
     string key;
    
     key.clear();
     key.append("a");
     ASK * Iptr = new ASK;    
     Iptr->ival = 10;
     Iptr->key.clear();
     Iptr->key.append(key);

     mymm2.insert(pair<string,ASK *>(key, Iptr));

     key.clear();
     key.append("a");
     Iptr = new ASK;    
     Iptr->ival = 20;
     Iptr->key.clear();
     Iptr->key.append(key);
    
     mymm2.insert(pair<string,ASK *>(key, Iptr));

     key.clear();
     key.append("b");
     Iptr = new ASK;    
     Iptr->ival = 30;
     Iptr->key.clear();
     Iptr->key.append(key);
    
     mymm2.insert(pair<string,ASK *>(key, Iptr));


    
     key.clear();
     key.append("a");
     ret = mymm2.equal_range(key);
    
     int cnt(0);
     for (iter=ret.first; iter!=ret.second; ++iter) {         
          printf("ival:%d key:[%s]\n", (*iter).second->ival,   (*iter).second->key.c_str() );         
                    // delete this single entry
                    //   mymm2.erase(????);
     }    

    
      printf("\n");

     printf("2nd pass after 'a' erase\n");
     ret = mymm2.equal_range(key);
     for (iter=ret.first; iter!=ret.second; ++iter) {
          printf("ival:%d key:[%s]\n", (*iter).second->ival,   (*iter).second->key.c_str() );    
     }
      printf("\n");


     key.clear();
     key.append("b");
     ret = mymm2.equal_range(key);
     for (iter=ret.first; iter!=ret.second; ++iter) {
          printf("ival:%d key:[%s]\n", (*iter).second->ival,   (*iter).second->key.c_str() );    
     }
      printf("\n");

}
//----------------------------------------------------------------------------------------------------------------
AnswerRe: re: probelms erasing a multimap entry Pin
«_Superman_»2-Dec-09 12:25
professional«_Superman_»2-Dec-09 12:25 
GeneralRe: re: probelms erasing a multimap entry Pin
Alan Kurlansky3-Dec-09 2:51
Alan Kurlansky3-Dec-09 2:51 
QuestionTransparentBlt doesn't mask transparent color with 4-bit and 8-bit source bitmaps Pin
sashoalm2-Dec-09 8:53
sashoalm2-Dec-09 8:53 
AnswerRe: TransparentBlt doesn't mask transparent color with 4-bit and 8-bit source bitmaps Pin
Richard MacCutchan2-Dec-09 12:01
mveRichard MacCutchan2-Dec-09 12:01 
GeneralRe: TransparentBlt doesn't mask transparent color with 4-bit and 8-bit source bitmaps Pin
Rozis2-Dec-09 12:33
Rozis2-Dec-09 12:33 
GeneralRe: TransparentBlt doesn't mask transparent color with 4-bit and 8-bit source bitmaps Pin
Richard MacCutchan2-Dec-09 13:07
mveRichard MacCutchan2-Dec-09 13:07 
GeneralUsing a palette Pin
sashoalm2-Dec-09 17:43
sashoalm2-Dec-09 17:43 
GeneralRe: Using a palette Pin
Richard MacCutchan2-Dec-09 23:43
mveRichard MacCutchan2-Dec-09 23:43 
GeneralRe: Using a palette Pin
Rozis4-Dec-09 1:33
Rozis4-Dec-09 1:33 
GeneralRe: Using a palette Pin
Richard MacCutchan4-Dec-09 23:17
mveRichard MacCutchan4-Dec-09 23:17 
AnswerRe: TransparentBlt doesn't mask transparent color with 4-bit and 8-bit source bitmaps Pin
Rozis2-Dec-09 12:15
Rozis2-Dec-09 12:15 
Question[Message Deleted] Pin
vtech222-Dec-09 7:32
vtech222-Dec-09 7:32 
QuestionRe: Menu Program Pin
David Crow2-Dec-09 7:35
David Crow2-Dec-09 7:35 
Answer[Message Deleted] Pin
vtech222-Dec-09 7:39
vtech222-Dec-09 7:39 
QuestionRe: Menu Program. Pin
David Crow2-Dec-09 7:42
David Crow2-Dec-09 7:42 
AnswerRe: Menu Program. Pin
vtech222-Dec-09 7:44
vtech222-Dec-09 7:44 
QuestionRe: Menu Program. Pin
David Crow2-Dec-09 7:53
David Crow2-Dec-09 7:53 

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.