?
Solved

LinkedList data structure ... also synchronized?

Posted on 2006-06-13
7
Medium Priority
?
353 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
Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

 
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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.
Suggested Courses
Course of the Month11 days, 13 hours left to enroll

752 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