Simple Linked List question.

Status
Not open for further replies.
Level 11
Joined
Oct 11, 2012
Messages
711
Hi, all. Can anyone explain what each line means? Thanks a lot!
JASS:
set this.next = 0   //Adding the instance or node at the end of the list ? Because the next node is nothing.
set this.prev = thistype(0).prev  // What does "thistype(0)" mean? The last node we just added? So this line links the new node to the previous node?
set thistype(0).prev.next = this //Links the previous node with new node?
set thistype(0).prev = this //What does this line do?.......
 
By convention struct instances starts to 1 and ends to 8190, here instead of declaring a new static struct member, the instance 0 is used to store the last member of the list, prev is used, but it could be next aswell.
Personnaly because it's really not clear that way, instead of using thistype(0).prev i would just use a static member spelled last. (hell that's not like adding one global variable will matter, readability of a code is not an option)

thistype(0) means we use the instance 0 of the current struct.

Is it clear now ?
 
By convention struct instances starts to 1 and ends to 8190, here instead of declaring a new static struct member, the instance 0 is used to store the last member of the list, prev is used, but it could be next aswell.
Personnaly because it's really not clear that way, instead of using thistype(0).prev i would just use a static member spelled last. (hell that's not like adding one global variable will matter, readability of a code is not an option)

thistype(0) means we use the instance 0 of the current struct.

Is it clear now ?

Yup, crystal clear! Thanks, +rep.
 
Status
Not open for further replies.
Back
Top