How to make map with two kwys. I am using struct.
struct Key
{
char * gi;
char * offset;
Key(const char * _gi, const char * _offset)
{
gi = new char [strlen(_gi) + 1];
strcpy(gi, _gi);
offset = new char [strlen(_offset) + 1];
strcpy(offset, _offset);
}
~Key()
{
if (gi != NULL)
{
delete [] gi;
gi = NULL;
}
if (offset != NULL)
{
delete [] offset;
offset = NULL;
}
}
};
struct Value
{
char * orient;
char * allele ;
Value(const char * _orient, const char * _allele)
{
orient = new char [strlen(_orient) + 1];
strcpy(orient, _orient);
allele = new char [strlen(_allele) + 1];
strcpy(allele, _allele);
}
~Value()
{
if (orient != NULL)
{
delete [] orient;
orient = NULL;
}
if (allele != NULL)
{
delete [] allele;
allele = NULL;
}
}
};
struct ltstr
{
bool operator()(const Key* _lhs, const Key* _rhs) const
{
return (strcmp(_lhs->gi,_rhs->gi) > 0 && strcmp(_lhs->offset,_rhs->offset) );
}
};
Key key ("34", "abcd");
Value value ("sdf", "asdf");
n.insert(dbmap::value_type(&key,&value));
When i try to retrieve the keys and values using iterator to map, i am not getting anything.
Can you tell me where i am wrong?
I will be really thankful if you can help me.
Regards
Man