• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

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?.......
 
Level 17
Joined
Apr 27, 2008
Messages
2,455
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 ?
 
Level 11
Joined
Oct 11, 2012
Messages
711
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.
Top