Array, Dictionary, HashTable for storing Bools.

I have a bunch of Bools i would like to store in a separate class for Getting and Stetting.

i just finished hashing my animations out and thought it would be nice to add some Bools that are used between a few scripts and add them to that HashTable.

Would an Array or Dictionary be better?

Dictionary’s advantage is being able to tie values to keys, so each animation could be specified as a key with a boolean value. It’s also quite easy to use. The same can be done with arrays however multi-dimensional arrays aren’t as easy to work with, but you will be able to iterate through an array faster with no memory allocations.

If performance isn’t a problem (and keep in mind, this is just a micro-optimization. It really only makes a difference if you have thousands of entries), then I’d say go with Dictionary for readability and ease of use.

edit: A multi-dimensional array isn’t necessary either. For instance you could define an enum and fill it with your various animations for readability i.e. Animations.ANIM_IDLE_01, then just set up an array and its length according to your total animation count.

Thankyou Crayz. Performance isn’t a problem for me at all but ease of use sure is. Dictionary it is MSDN here i come!

1 Like

bitmask enumeration would work better still…

1 Like

I cant say i have ever hear of that. I will have to do a search for that. Thank you James.

this link should cover your needs.

http://stackoverflow.com/questions/3261451/using-a-bitmask-in-c-sharp

1 Like