• 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:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Internal Implementation of Linked List ?

 
Ranch Hand
Posts: 230
IntelliJ IDE Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What is the internal Implementation of Linked List ?

In case if I want to create a custom Linked List then what should I use ?
 
Sheriff
Posts: 5555
326
IntelliJ IDE Python Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
A Linked List is a generic data structure used in computer science that you'll find in a lot of programming languages. You'll most likely find that they've been implemented differently in each language too. If you're particularly interested in how Java implements it then you can take a look at the OpenJDK source for java.util.LinkedList. You may find that the Oracle version is implemented differently, but it's quite unlikely to be any different.

I'm not sure what exactly you're thinking of when you say you want to create a "custom Linked List"? You can write a class that implements java.util.List and write it as a Linked List.
 
Rancher
Posts: 3742
16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Tim Cooke wrote:You may find that the Oracle version is implemented differently, but it's quite unlikely to be any different.


There was a similar conversation a few weeks ago. It turned out that the implementation varies even within the Oracle versions. Java 6 is different to Java 7.
 
Bartender
Posts: 10780
71
Hibernate Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Santosh Kumar Nayak wrote:What is the internal Implementation of Linked List ?


Very simply, it's based on "Nodes" that point to each other, viz:It doesn't show the whole implementation, but that's the basic structure for a doubly-linked list; for a single-linked list you just remove the 'prev' pointer.
To "insert" values, you simply change the pointers so that "neigbours" point to a new Node, and to remove one you change its neighbours so that they point to each other. It's a bit fiddly at first - especially with doubly-linked Nodes - but you'll soon get the hang of it.

There's quite a good set of diagrams in the Wiki page on the subject, which may also help you to work out what's going on.

HIH

Winston
 
reply
    Bookmark Topic Watch Topic
  • New Topic