Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

LinkedList data structure ... also synchronized?

Posted on 2006-06-13
7
Medium Priority
?
355 Views
Last Modified: 2010-03-31
I need to implement a linkedlist type of datastructure, where nodes are linearly ordered, nodes are inserted and removed at various positions in the list.

I began experimenting with java's LinkedList class, but it provides no method to insert a node into a list. So do I need to create a new class from scratch or can I somehow append the LinkedList class?

Am I better off implementing my own data structure?

Also there is an example of implemented linked list here:
http://examples.oreilly.com/jenut/LinkedList.java
but I don't quite understand the importance of synchronizing, can anyone give an example as to when its necessary?

Also does implementing the linkable interface do anything for the synchronization?

0
Comment
Question by:polkadot
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
7 Comments
 
LVL 24

Expert Comment

by:sciuriware
ID: 16896121
If only one thread manipulates the list synchronisation is not necessary.
Otherwise, you need a Vector or must do all the synchronising yourself.

;JOOP!
0
 
LVL 24

Expert Comment

by:sciuriware
ID: 16896128
... the latter means that all methods that may access the linked list have the keyword   synchronised.


This synchronisation costs overhead!!

;JOOP!
0
 
LVL 24

Expert Comment

by:sciuriware
ID: 16896149
use methods like  .add(int index, E element) to add a node at a position.

;JOOP!
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 24

Accepted Solution

by:
sciuriware earned 2000 total points
ID: 16896165
Find all other methods you need at http://java.sun.com/j2se/1.4.2/docs/api/java/util/LinkedList.html

;JOOP!
0
 
LVL 30

Expert Comment

by:Mayank S
ID: 16900704
>> but it provides no method to insert a node into a list.

? Meaning inserting between a list?

0
 
LVL 24

Expert Comment

by:sciuriware
ID: 16900877
I think he means at random position.

;JOOP!
0
 
LVL 24

Expert Comment

by:sciuriware
ID: 16917942
:<)
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
Suggested Courses

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question