So based on your explanation, the second one is no good?
The second one can be good if you destroy the struct before the end of the func and if you don't need the struct instance anymore.
Infact create and allocate are the same. But in the tutorial I redefined the create method so to create an instance inside the struct I have to call the allocate
But outside I want to use my create function which does more thing than the allocate function only.
Linked list isn't that much useful.
And btw Mag is a fan of extends array so don't really care of this until you fully understand
In your second method you init your struct instance and then you do some stuff and at least you don't return your struct instance.
So -> If you do this way you will lost the pointer to your struct instance. Infact it will be lost in the desert plains of vJASS XD !
And more you will not be able to destroy it and so you will have an index non used anymore ^^
local group g = CreateGroup()
local unit u
local unit array data
local integer index = 0
//Pick your group
set u = FirstOfGroup(g)
exitwhen u == null
set data[index] = u
set index = index + 1
//u will hold the random unit
set u = data[GetRandomInt(0,index)]
Linked List -> One sense of direction (don't know if it means the same as in french xD)
Circular -> Two sense of direction. The first to loop through, the second to recycle !
Thanks for the compliment !
EDIT : But to be honest dunno how to do singly linked list to do recycle and loop ^^'
EDIT2 : Maybe two singly linked list works like this . But this will looks like circular at one moment ^^
EDIT3 : Ah yes ... I remember now, they are using the head/prev/next thingy.
Infact when using linked list it isn't faster than dynamic indexing when non extending array ...
And it is matter of nanoseconds so just pick your favorite... I'm starting to get bored of linked list, besides it is me who revived the circular linked list xD !
And you're right about the typo !!
Thanks for pointing this out !
I'll submit this if you think it is good. -> I'll rep you for reviewed it
Btw the theory is the same ^^
Ah! No, don't worry about that. It's okay to ask anything dude, it's easier to understand (new) things if you ask questions, it's not bothering me (or perhaps, anyone here). I used to do that too when I was new to vjass.
Why do you sound mad? I just said I dunno how to use alloc...
EDIT: Oh! you must be referring about the jasshelper manual post I made! Please don't be mad, I was replying to the post above mine and not your post dude. Sorry about that, I hope I didn't hurt your feelings man.
Alloc isn't really a good idea ....
Because if you want to use struct extends array it is because you need another allocator (like when using something special like in my Fear Explosion) not to use the same without protection ^^