• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

Linked List Simple question?!?

 
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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...
 
author and iconoclast
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
lowercase baba
Posts: 13091
67
Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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!!

 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic