Group

Share your ZGE-development tips and techniques here!

Moderator: Moderators

Post Reply
User avatar
Kjell
Posts: 1715
Joined: Sat Feb 23, 2008 11:15 pm

Group

Post by Kjell » Tue Apr 26, 2011 2:46 pm

: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
Attachments
Group.zgeproj
Now with increased performance ~
(6.79 KiB) Downloaded 357 times

StevenM
Posts: 149
Joined: Thu Jan 20, 2011 10:03 am

Post by StevenM » Mon May 02, 2011 1:44 am

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?

User avatar
Kjell
Posts: 1715
Joined: Sat Feb 23, 2008 11:15 pm

Post by Kjell » Mon May 02, 2011 10:55 am

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

Post Reply