Hello,
Do you think possible to extend the language to allow the declaration of maps of array like int[][string] or real[][string] ?
Best regards.
Hello,
Do you think possible to extend the language to allow the declaration of maps of array like int[][string] or real[][string] ?
Best regards.
yes, but i don’t like is syntax.
and I am not sure to understand what you want,
can you explain in C++ what is the key type of the map and the mapped value type.
remark: make a double as a key value is not a good idea due to roundoff error.
to day your can do
real[string] mapr;
int[string] mapi;
mapr[2.15]= 6.6;
mapi[2]= 7;
// here 2.15 is cast in string "2.15" and 2 in string "2" automatically
we misunderstood each other, the key value is always either a string or a int. The idea is have these two objects :
map<string, int>
map<string, real>
map<string, string>
map<int, int>
map<int, real>
map<int, string>
Best regards.
Yes for
map<string, int[]>
map<string, real[]>
map<string, string[]>
this syntaxe is clear
int[string][int]
real[string][int]
string[string][int]
but for this other we can not used
int[int][int]
real[int][int]
string[int][int]
because it is array of array not map .
I better understand. Do you know when map<string,T> will be available ?
Let’s suppose ID (from a medit or gmsh mesh file) be either an int or a string, the motivation comes from the need to store solid IDs according to materials IDs (that goes the same for surface IDs according to boundary condition IDs), ids are not necesserary 0-index and must be arbitrary “big”, it’d be a pity to not use a sparse structure for IDs such as maps.
So that i could write :
int[string][int] MaterialID;
MaterialID[“45757”] = [1214,2354,396,14];
MaterialID[“14664”] = [567,47787,12];
and
cout<<"Size = "<<MaterialID.n<<endl;
cout<<MaterialID<<endl;
Size = 2
2
1214 2354 396 14 4
567 47787 12 3
cout<<MaterialID[“14664”][2]<<endl;
cout<<MaterialID[“14664”].n<<endl;
12
3
Best regards.
no today, It depend strongly of your need!
Best Regards,
Frédéric Hecht.