• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Linked List Simple question?!?

 
Nadine Ernest
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
so im a bit confused about the




what does it mean?
does it mean the previous of the current and then the next of the previous of the previous current which is the current itself.............i know thats wrong soooo how do i not confuse it again"???


and explain please this one too

???

thanks in advance...
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24212
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Nadine,

Actually, you explained it correctly. If "current", "previous", and "next" are all links to nodes in a linked list, and each node has members named "previous" and "next", and "current" points to some node of interest that is not the very first node in the list, then "current.previous.next" would be the node after the node before the current node -- or the current node itself. Similarly, if "first" points to some node which is not the last node in the list, then "first.next.previous" would be the node before the node after first -- i.e., first.
 
fred rosenberger
lowercase baba
Bartender
Posts: 12196
35
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
the dot operators go left to right. so, the first one is saying

take the current object, get its previous reference, and then take THAT things next reference.

Assuming current points to the nth object, current.previous would give you the (n-1)th object. You then get the next reference from the (n-1)th, which should give you the nth.

your second example is similar. first should point to the 1st object. you then get the reference to the next object, which would give you the 2nd. you then get the previous reference from the 2nd, putting you back at the 1st.
 
Nadine Ernest
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ernest Friedmann Hill : thank you soo much ,, you made it really simple for me to understand it!! its an honor to have you here to help us in our problems!!

Fred Rosenberger : thanks ,,, i got it now!!

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic