wc3campaigns
WC3C Homepage - www.wc3c.netUser Control Panel (Requires Log-In)Engage in discussions with other users and join contests in the WC3C forums!Read one of our many tutorials, ranging in difficulty from beginner to advanced!Show off your artistic talents in the WC3C Gallery!Download quality models, textures, spells (vJASS/JASS), systems, and scripts!Download maps that have passed through our rigorous approval process!

Go Back   Wc3C.net > Resources > Code Resources > Scripts
User Name
Password
Register Rules Get Hosted! Chat Pastebin FAQ and Rules Members List Calendar



Reply
 
Thread Tools Search this Thread
Old 04-20-2009, 03:55 PM   #16
grim001
requires vJass
 
grim001's Avatar


Code Moderator
 
Join Date: Nov 2006
Posts: 1,540

Submissions (10)

grim001 is just really nice (277)grim001 is just really nice (277)

Send a message via AIM to grim001
Default

Will do.
grim001 is offline   Reply With Quote
Sponsored Links - Login to hide this ad!
Old 05-06-2009, 05:35 PM   #17
grim001
requires vJass
 
grim001's Avatar


Code Moderator
 
Join Date: Nov 2006
Posts: 1,540

Submissions (10)

grim001 is just really nice (277)grim001 is just really nice (277)

Send a message via AIM to grim001
Default

Updated documentation, added a .getRandom method, though I don't expect it to be used much.
grim001 is offline   Reply With Quote
Old 08-04-2009, 10:52 AM   #18
maskedpoptart
User
 
Join Date: Jan 2009
Posts: 10

maskedpoptart has little to show at this moment (0)

Default

private static thistype length = 0 Why is length of type "thistype"? It's supposed to be an integer, right?
maskedpoptart is offline   Reply With Quote
Old 08-04-2009, 02:20 PM   #19
grim001
requires vJass
 
grim001's Avatar


Code Moderator
 
Join Date: Nov 2006
Posts: 1,540

Submissions (10)

grim001 is just really nice (277)grim001 is just really nice (277)

Send a message via AIM to grim001
Default

Correct.

I'm going to have to actually open the editor soon with all these bugs piling up...
grim001 is offline   Reply With Quote
Old 12-12-2009, 10:44 AM   #20
grim001
requires vJass
 
grim001's Avatar


Code Moderator
 
Join Date: Nov 2006
Posts: 1,540

Submissions (10)

grim001 is just really nice (277)grim001 is just really nice (277)

Send a message via AIM to grim001
Default

This resource has been revived. The documentation and code have been given an overhaul. This thing is pretty awesome, so please bother to read the description.

I've also merged UntiListModule into this thread. The two libraries are too similar to be split apart, seriously.

Finally, if you actually use UnitListModule, you will need to update to the latest AutoIndex version.

Last edited by grim001 : 12-12-2009 at 02:13 PM.
grim001 is offline   Reply With Quote
Old 12-18-2009, 05:15 AM   #21
grim001
requires vJass
 
grim001's Avatar


Code Moderator
 
Join Date: Nov 2006
Posts: 1,540

Submissions (10)

grim001 is just really nice (277)grim001 is just really nice (277)

Send a message via AIM to grim001
Default

Updated...

List:
  • count, first, last, next, and prev are no longer methods. They are now readonly instance members. This shortens the code quite a bit, and makes iterating prettier.

UnitList:
  • unitNext and unitPrev are now readonly instance members rather than methods.
  • "me" is now readonly, as it should have been to begin with.
  • You can now call unitListAdd(u) on an instance that is already in a unit's list, and it will be removed from its current list and added to the specified unit's list.
  • Fixed a bug involving creating instances while unitListDestroy was in progress.

Edit:
  • Revived the Set module and placed it in the first post. I realized once again that it has distinct uses aside from the List module. Sometimes that StructName[n] syntax is important.

Last edited by grim001 : 12-24-2009 at 04:00 PM.
grim001 is offline   Reply With Quote
Old 12-28-2009, 05:27 AM   #22
weaaddar
User


Respected User
 
Join Date: Apr 2002
Posts: 2,372

Submissions (3)

weaaddar has a spectacular aura about (131)

Default

I don't really think that the set module is that useful. Since an enduser can't tell if a struct is part of the "set" (unless the assumption is that everything is part of the set that isn't destroyed?). If you are chaining all your elements into the set, then you can simply use StructName(number) and probably work just as well.

The inset boolean is private to the module, so its kind of a downer.

As for the linked list, its only faster if its a linear linked list not a circular linked list. Circular linked list is slower to traverse then an array as you have to do for(n = list.first; n < list; n = n.next) which requires more array reads and thats slower then i+=1.

And holy shit there is a readonly keyword? When was this added!

Also looking over this you really can probably tighten up the linked list code. Do something like what I do in my Dictionary, have in your case the list itself hijack the variables of the 0th array element and that way you can simplify your add and remove. So that you don't have to care if its element the first, last or middle element in the linked list.

e.g.
Collapse Zinc:
static method operator first()->integer
{
     return thistype(0).next;
}
static method operator prev()->integer
{
     return thistype(0).prev;
}

Then add & remove can literally be this
Collapse Zinc:
    method listAdd takes nothing returns nothing
        if inlist or destroying then
            return
        endif
        set inlist = true
        set last.next = this
        set prev = last
        set last = this
        set count = count + 1
    endmethod

  method listRemove takes nothing returns nothing
        if not inlist then
            return
        endif
        set inlist = false
        set prev.next = next
        set next.prev = prev
        set count = count - 1
    endmethod
Sure these are all very minor gropes. But since you sort of skipped the review process for setModule I felt i should nitpick :P

Last edited by weaaddar : 12-28-2009 at 05:42 AM.
weaaddar is offline   Reply With Quote
Old 12-28-2009, 05:40 AM   #23
grim001
requires vJass
 
grim001's Avatar


Code Moderator
 
Join Date: Nov 2006
Posts: 1,540

Submissions (10)

grim001 is just really nice (277)grim001 is just really nice (277)

Send a message via AIM to grim001
Default

Quote:
Originally Posted by weaaddar
I don't really think that the set module is that useful. Since an enduser can't tell if a struct is part of the "set" (unless the assumption is that everything is part of the set that isn't destroyed?). If you are chaining all your elements into the set, then you can simply use StructName(number) and probably work just as well.
You are supposed to add every instance to the set. Same with the List module. That would be automatic once modules support it. The modules are strictly for keeping a collection of every allocated instance of your struct, which is a very common task.

Quote:
Originally Posted by weaaddar
As for the linked list, its only faster if...
I benchmarked it. The method described in the documentation is 12% faster than standard array iteration (before anything is added to the loop, which would make the difference proportionally less significant). I guess it's enough that ListModule should be preferred when possible, though.

Iteration looks like this:
Expand JASS:
As you can see, that's fewer operations than a normal array loop, since you don't have to decrement/increment any counter.

Quote:
Originally Posted by weaaddar
And holy shit there is a readonly keyword? When was this added!
A long time ago. It's rarely used because at first it was considered a temporary feature. Eventually it was adopted as a permanent feature, but by then everyone forgot about it...

Quote:
Originally Posted by weaaddar
Then add & remove can literally be this
Looks like a good suggestion, I will change it if it works as expected.

Quote:
Originally Posted by weaaddar
But since you sort of skipped the review process for setModule I felt i should nitpick :P
I'm not allowed to do that. See this thread: SetModule. In other words, it was already approved.

Last edited by grim001 : 12-28-2009 at 06:00 AM.
grim001 is offline   Reply With Quote
Old 12-28-2009, 05:59 AM   #24
weaaddar
User


Respected User
 
Join Date: Apr 2002
Posts: 2,372

Submissions (3)

weaaddar has a spectacular aura about (131)

Default

Sorry didn't mean to call you dishonest. I think those minor improvements I suggested should help. And yeah I see the manual says not to use them as its a temporary fix.
I did some testing and my results were different:: http://www.thehelper.net/forums/showthread.php?t=142053

I was testing retrieval, so I think it sprobably the layer of indirection that makes the .object fetch slower then array fetch.
weaaddar is offline   Reply With Quote
Old 12-29-2009, 01:34 AM   #25
grim001
requires vJass
 
grim001's Avatar


Code Moderator
 
Join Date: Nov 2006
Posts: 1,540

Submissions (10)

grim001 is just really nice (277)grim001 is just really nice (277)

Send a message via AIM to grim001
Default

  • Updated ListModule to have more efficient add/remove methods as per weaaddar's suggestion.
grim001 is offline   Reply With Quote
Old 01-06-2010, 10:24 AM   #26
Troll-Brain
User
 
Join Date: Oct 2006
Posts: 1,490

Submissions (1)

Troll-Brain has a spectacular aura about (134)

Default

I was looking about UnitListModule, but apparently you need to fix the code or at least the example.
And do something more-up-to-date with the new vJass features.

Last edited by Troll-Brain : 01-06-2010 at 10:29 AM.
Troll-Brain is offline   Reply With Quote
Old 01-06-2010, 11:26 AM   #27
grim001
requires vJass
 
grim001's Avatar


Code Moderator
 
Join Date: Nov 2006
Posts: 1,540

Submissions (10)

grim001 is just really nice (277)grim001 is just really nice (277)

Send a message via AIM to grim001
Default

Quote:
Originally Posted by Troll-Brain
I was looking about UnitListModule, but apparently you need to fix the code or at least the example.
And do something more-up-to-date with the new vJass features.

What the heck are you talking about? Your post is totally vague and doesn't even indicate what your problem is. There's nothing wrong with the code or the example, nor does it fail to use any current features.

Last edited by grim001 : 01-06-2010 at 11:27 AM.
grim001 is offline   Reply With Quote
Old 01-06-2010, 11:42 AM   #28
Troll-Brain
User
 
Join Date: Oct 2006
Posts: 1,490

Submissions (1)

Troll-Brain has a spectacular aura about (134)

Default

It doesn't compile.
Also :
Quote:
// The requirement to call unitListAdd() and unitListRemove() will be done
// away with once JassHelper supports module onDestroy and module onCreate, but
// for now, it is not too much of a burden.
But this thing is still maybe not allowed yet , i thought it was but didn't test it, sorry if i'm wrong.

Last edited by Troll-Brain : 01-06-2010 at 11:45 AM.
Troll-Brain is offline   Reply With Quote
Old 01-06-2010, 12:28 PM   #29
grim001
requires vJass
 
grim001's Avatar


Code Moderator
 
Join Date: Nov 2006
Posts: 1,540

Submissions (10)

grim001 is just really nice (277)grim001 is just really nice (277)

Send a message via AIM to grim001
Default

Quote:
Originally Posted by Troll-Brain
It doesn't compile.
It compiles just fine, you must be doing something wrong.

Quote:
Originally Posted by Troll-Brain
But this thing is still maybe not allowed yet
onCreate doesn't exist yet, much less module onCreate. Module onDestroy isn't supported either.

Last edited by grim001 : 01-06-2010 at 12:30 PM.
grim001 is offline   Reply With Quote
Old 01-06-2010, 12:44 PM   #30
Troll-Brain
User
 
Join Date: Oct 2006
Posts: 1,490

Submissions (1)

Troll-Brain has a spectacular aura about (134)

Default

Quote:
Originally Posted by grim001
It compiles just fine, you must be doing something wrong.

Collapse JASS:
library test initializer onInit uses UnitListModule

struct Example
        implement UnitList
        
        static method create takes unit u returns Example
            local Example this = allocate()
                call unitListAdd(u) //This instance has been added to this unit's list.
            return this
        endmethod
        
        static method onDestroy takes nothing returns nothing
            call BJDebugMsg("destroy")
            call unitListRemove()  //This instance has been removed from the unit's list.
        endmethod
    endstruct

private function onInit takes nothing returns nothing
    local unit u = CreateUnit(Player(0),'hpea',0.,0.,0.)
    local Example s = Example.create(u)
    call TriggerSleepAction(1.)
    call RemoveUnit(u)
endfunction

endlibrary

"onDestroy must be an instance method" (Jasshelper 0.A.2.A)

I've removed the static but don't say the example compile fine
with this example i got an other error, UnitListModule_AddUnitList undeclared, probably because of how jasshelper handle initializer.

Could you fix it or must we use work arounds ?
I won't probably have to need to create a struct inside an initializer though, it was just for a quick test.

EDIT :

Nevermind i've forgotten the keyword "uses UnitListModule" ><

Quote:
onCreate doesn't exist yet, much less module onCreate. Module onDestroy isn't supported either.
Sorry, then.

Last edited by Troll-Brain : 01-06-2010 at 01:01 PM.
Troll-Brain is offline   Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off


All times are GMT. The time now is 03:27 AM.


Affiliates
The Hubb The JASS Vault Clan WEnW Campaign Creations Clan CBS GamesModding Flixreel Videos

Powered by vBulletin (Copyright ©2000 - 2019, Jelsoft Enterprises Ltd).
Hosted by www.OICcam.com
IT Support and Services provided by Executive IT Services