Way to add some sort multimensionality as in array but in OwnedArray?


I created an OwnedArray Object to hold undefined number of button objects. I would like to know which is in your opionion the best/elegant way to add some sort multimensionality as in array but in OwnedArray. Would you use the name property of the id property for that?

names like: button1_1








Probably is not a good aproach, any thoughts?

Should i overight of the button class to add some sort of indexation? is there any alternatives? or litle snippets i could look for?


Thank you much,



This totally depends on what you're actually trying to do, and the scale.  Is the array to be rectangluar?  Is it being used as a small core container in a single class, or something that is used widely?

If it's a rectangle data structure, and used in a pretty humble way, you could simply use a one-dimensional array and index with (y * w) + x.

For more widely used code, probably you should create a container class that uses an OwnedArray internally, but exposes a two-dimensional array to outside code.  Again the internals would likely just be a 1-d array with offset indexing, unless the array is of non-uniform dimensions.  You can always use an array of arrays, but I personally wouldn't even make this my first (or even second) choice.








An OwnedArray inside an OwnedArray inside an OwnedArray inside an OwnedArray....



It has to be simple has it's very widly used  so i will have in mind your advice ;) 

Again Thumbs up!