• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[Solved] which group recycling system do you use?

Status
Not open for further replies.
Level 6
Joined
Oct 23, 2011
Messages
182
Question about group recycling

I don't know what to choose between GroupUtils at wc3c.net or Recycle at THW.
Also, how does this stack thingy work?

JASS:
        static method get takes nothing returns group
            if .index == 0 then
                return CreateGroup()
            endif
            set .index = .index - 1
            return thistype[.index].handles
        endmethod

after the first .get, how does it return a group without creating it? with negative index??
am I supposed to release specific amount of groups at initialization of the map and use .get to retrieve it?
I thought i was supposed to replace CreateGroup() with group.get and DestroyGroup() with group.release

GroupUtils also perform ' set .index = .index - 1 ' only if index isn't zero while Recycle does.
 
Last edited:

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,258
When ever I need a group recycling system, I just write my own. No need for all the funky vJASS ones when you can do it was a few functions and a global block (which is one of the few features next to name spacking I use from vJASS).

Also be aware that for a lot of opperations you can get away with using a constant group. You only need group recycling if you need to store group contense persistantly for a dynamic structure (to replace constructors and destructors).
 
IMO, use Recycle from THW or TH. GroupUtils isn't really needed if you code your groups properly. (especially since the null leak no longer exists) The main part you need is just recycling, but that is easy to do either by yourself or with the Recycle library. (which is pretty handy)

after the first .get, how does it return a group without creating it? with negative index??
am I supposed to release specific amount of groups at initialization of the map and use .get to retrieve it?
I thought i was supposed to replace CreateGroup() with group.get and DestroyGroup() with group.release

Look at the release function.
JASS:
set $name$[$name$.index].handles = h
set $name$.index = $name$.index + 1

That will put the group that was released into the recycle stack. The only way it will recycle is if a group has been released.

For example:
- you call group.get(), it will return CreateGroup()
- you call group.get(), it will return CreateGroup() again because there are no groups that have been released yet
- you call group.release(), now that group will go into the recycle stack
- you call group.get(), it will return that group that was recycled instead of creating a new one

GroupUtils also perform ' set .index = .index - 1 ' only if index isn't zero while Recycle does.

If the index is 0 it will return CreateGroup()
 
Level 6
Joined
Oct 23, 2011
Messages
182
IMO, use Recycle from THW or TH. GroupUtils isn't really needed if you code your groups properly. (especially since the null leak no longer exists) The main part you need is just recycling, but that is easy to do either by yourself or with the Recycle library. (which is pretty handy)



Look at the release function.
JASS:
set $name$[$name$.index].handles = h
set $name$.index = $name$.index + 1

That will put the group that was released into the recycle stack. The only way it will recycle is if a group has been released.

For example:
- you call group.get(), it will return CreateGroup()
- you call group.get(), it will return CreateGroup() again because there are no groups that have been released yet
- you call group.release(), now that group will go into the recycle stack
- you call group.get(), it will return that group that was recycled instead of creating a new one



If the index is 0 it will return CreateGroup()

thank you. cleared up everything for me =)
 
Status
Not open for further replies.
Top