codetoad.com
  ASP Shopping CartForum & BBS
  - all for $20 from CodeToad Plus!
  
  Home || ASP | ASP.Net | C++/C# | DHTML | HTML | Java | Javascript | Perl | VB | XML || CodeToad Plus! || Forums || RAM 
Search Site:
Search Forums:
  Problem with hash map  bellederer at 02:21 on Wednesday, February 16, 2005
 

Hello, I am having trouble working with hash_map. I am adding a key-value pair to the map, but when I exit the function it disappears. Here is my code:

SymTabErr SymTabMgr::enter(SymTabEntry* se)
{
SymTab *table;
SymTab st;
SymTabEntry *entry;
size_t x;

mainStack->pop(table);
x = table->count(se->name());
st = *table;
if (x == 0){ //this element doesnt exist yet
st[se->name()] = se; //add se to the hash map
mainStack->push(&st);
return SYMTAB_OK;
}
}

SymTab is a hash_map, which is a collection of SymTabEntry values. The keys are the "names" of the SymTabEntry that is being added. "st[se->name()] = se;" is the line that adding the new data. For the life of this function the data is there, but when I reenter this function the hash_map is empty!
The a pointer to the hash_map is being saved on a global stack.

Thanks for your help!



© Copyright codetoad.com 2001-2005