A
anjangoswami06
Hi,
I am interested to know how it is possible to update the data type with
"insert" with stl hash_map. Suppose we have,
hash_map<const char *, MyDataType, hash_compare<const char*,
some_compare_func_obj>>
x;
//I want to insert a new instance of MyDataType if a new key is
encountered but if it is a key //which already exists I want to update
the existing values of the members of MyDataType //instance which is
associated with the key.
//MyDataType may be as follows:
struct MyDataType {
int x;
int y;
char[2048] str;
MyDataType(){x=0;y=0; strcpy(str,"NONEYET"));
};
//one way of insertion is the following but I will not be able to
update already instanciated
//MyDataType in a straight manner.
x.insert(make_pair("some string",MyDataType data))
//I am trying to find a simple and elegant method for this.
I will appriciate any suggestion.
Thanks.
Buchan
I am interested to know how it is possible to update the data type with
"insert" with stl hash_map. Suppose we have,
hash_map<const char *, MyDataType, hash_compare<const char*,
some_compare_func_obj>>
x;
//I want to insert a new instance of MyDataType if a new key is
encountered but if it is a key //which already exists I want to update
the existing values of the members of MyDataType //instance which is
associated with the key.
//MyDataType may be as follows:
struct MyDataType {
int x;
int y;
char[2048] str;
MyDataType(){x=0;y=0; strcpy(str,"NONEYET"));
};
//one way of insertion is the following but I will not be able to
update already instanciated
//MyDataType in a straight manner.
x.insert(make_pair("some string",MyDataType data))
//I am trying to find a simple and elegant method for this.
I will appriciate any suggestion.
Thanks.
Buchan