简体   繁体   中英

Java.Util Linked List Implementation from Scratch

I would like to implement a singly linkedlist with functions that the java.util library does not contain such as: returning the middle node in a linked list and inserting a new head at the linkedlist. My question is: What type of linked list is the java.util linked list (eg. singly, doubly)? Secondly, I would be interested in knowing if you recommend me to implement linked lists from scratch. I care about being able to maintain my own code without third party libraries (because of the dependency) and being able to customise it. I also want to implement merge sort and I feel that having a middle node method is important. Thanks!!

The Java implementation of LinkedList is a doubly-linked list. Also, it already has the ability to add an element at the head/front (if I understood correctly).

Linked lists are relatively simple, so you can implement them from scratch if you like (there are plenty of tutorials if you do a simple search as well). However, if a third-party open source library meets your needs, I would highly recommend using it. It is likely to be far better maintained than anything you can manage. If you think it is falling behind or lacking, you can offer contributions.

For merge sort, not sure why you need it. Java collections already implements merge sort , and uses the most efficient and up to date algorithms available.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM