<<is it ok if I use iterator instead of iterator_const?>>

The only difference is that const_iterator won't let you write directly to an 
element. So, you should be fine using a plain ol' iterator.

<< Trouble is, in the long term I'd like to add GetIndType() and
GetIndResource() functionality to XBlockFile. And I guess there will surely
be only a couple of types, thus the gain from a hash map will probably be
very low. maybe I'll make XBlockFile remember the last type chosen and
check that first, which would speed up e.g. getting a list of all buttons.>>

For GetInd_() calls, you'll need something that you can easily keep sorted by 
ID numbers, and also will give you random access. Unfortunately, maps and 
hashmaps won't give you the latter. A vector would probably work well for 
this part, but we wouldn't want to maintain a vector just for these calls I 
don't think. Hmmm...

<< sounds like what I want to do. But how do I add items to a hashmap or to a
map?>>

You just assign them. You don't need to allocate the space or anything. Just 
say:

myhashmap["SOMEINDEX"] = someHashMapEntry;

OR

mymap[500] = someMapEntry;

OR for a hashmap of maps, as Anthony wrote before:

myhashmap["SOMEINDEX"][500] = someMapEntry;

In the resource fork style:

resources["MENU"][128] = myMenu;

You also mentioned that hashmaps may be overkill for the block types since 
there will only be a few. I agree on one hand, but on the other I don't think 
they will cause any harm, they are make for very readable code, and well, 
they'll be there in case we ever did have a lot of block types...

regards,
Brian


Reply via email to