• Check out the results of the Techtree Contest #19!
  • 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.
  • Create a void inspired texture for Warcraft 3 and enter Hive's 34th Texturing Contest: Void! Click here to enter!
  • The Hive's 22nd Icon Contest: Creep Abilities is now concluded, time to vote for your favourite set of icons! Click here to vote!

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