Hello, this is a newbie question, sorry for that,
I am trying to port some Java code to C++. In this code I have a hashmap connecting string values to float arrays of varying sizes. They are specified like this:
HashMap <String, float[]> hm = new HashMap <String, float[]> ();
hm.put("C", new float[] {
3, 0, 0 , 1, 0, 1 , 0, 1, 1 , 0, 5, 1 , 1, 6, 1 , 3, 6, 1
}
);
hm.put("D", new float[] {
0, 0, 0 , 2, 0, 1 , 3, 1, 1 , 3, 5, 1 , 2, 6, 1 , 0, 6, 1 ,
0, 0, 1
}
);
... and so on.
I can see there are lots of strategies for storing dynamic arrays and key to value lookups, but my problem is this: How do I define all these values in a similarly nice way without making some totally unwieldy frankenstein code? The only way I can see is to make a constant for each float array I want to store. Each of these would have to have a unique single variable name, which already negates the whole point of using arrays and containers! Any ideas would be appreciated.