Page 1 of 1

Group

Posted: Tue Apr 26, 2011 2:46 pm
by Kjell
:arrow:

Simple general purpose group data structure ( for models ) with basic demo visualizing the data map.

- Don't forget to reset the group before use.
- Make sure Group and GroupMap have the same SizeDim1.
- Iteration is done using "Group[GroupMap[E]]" where "E < GroupLength".

K

Posted: Mon May 02, 2011 1:44 am
by StevenM
Thanks for posting this Kjell - it's interesting.

If I am understanding this correctly - it would allow us to dynamically Add and remove any model within group of models? anyway this looks like it can be very useful for some thing that I want to do.

I'm trying to see how this is working. I'm not sure what the visual data represents.

Is this right?

The numbered colored blocks are the models and the "Modelkey" associated with them.

The rows represent the array size of the group.

The position of the model in the row is the array index number within the group.

Also what is the groupReset() function for?

Posted: Mon May 02, 2011 10:55 am
by Kjell
Hi Steven

Your statements are correct yes. The benefit of using this data structure over a plain array with dynamic models is that with a normal Array you'd have to loop through the entire array to iterate¹, and loop through the array searching for a empty spot when adding a Model². The delete behavior is pretty similar in performance though.

¹ While in the Group all used slots are kept at the beginning of the map.
² While in the Group the next empty spot is always known.

The groupReset function resets / initializes the group .. in order for the group to function, the GroupMap needs to be filled with all available slots ( so from 0 to 7 in the demo ) before usage.

K