File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes Collections (LinkedHashMap) Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Java in General
Reply Bookmark "Collections (LinkedHashMap)" Watch "Collections (LinkedHashMap)" New topic
Author

Collections (LinkedHashMap)

adrian mills
Ranch Hand

Joined: Dec 09, 2004
Posts: 63
Hi All,
Thanks in advance.

I am having some values stored in a linked hash map.
They are in the form of Key value pair.But since I had to maitain their order also I used a LinkedHashMap.

My problem is that while iterating I have to remove a particular value fromt the linkedhashmap.
For eg:

the linked hashmap contains the following values:--

("Am",1);
("Pm",2);
("Cm",3);
("Dm",4);

Now suppose I remove Pm.
Then the new hashmap should be formed in the following manner
("Am",1);
("Cm",2);
("Dm",3);

Can someone suggest me how to do this.
I tried iterating and removing and putting the value again in the linkedhashmap.but it gives a Concurrent modification exception.

Thanks a lot for all your help
Arjun Shastry
Ranch Hand

Joined: Mar 13, 2003
Posts: 1854
Are you trying to do this or am I wrong somehere? following code is not giving any error


MH
pascal betz
Ranch Hand

Joined: Jun 19, 2001
Posts: 547
hi

it looks like your value is just the index ?
then use a List instead of Map. The index of your objects would be the same as your values in the Map.

some pseudocode:




pascal
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: Collections (LinkedHashMap)
 
Similar Threads
collections framework
Need to store the result obtained within a while loop for further usage
Recursion and linked lists
Java collections - how frequently do you use them in development ?
how to change the order of a Linked hashMap