• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Linked Hash Map

 
sreedhar Lackka
Ranch Hand
Posts: 154
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,
Thanks a lot in advance.

We are planning to use cache but we dont have any cache mechanism in the cache actually there should be some thing which provide the key, value and entry iteration that are consistent with an order of entry.
For this we came up with two approaches indexing that list and LisnkedHashMap.
But dont know what are disadvantages and overheads with LinkedhashMap.
Please give me some useful information and suggestions on this.

Regards,
Sree
 
Sagar Rohankar
Ranch Hand
Posts: 2907
1
Java Spring Ubuntu
 
Dariusz Kordonski
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you need ordered key-value entries, then I think LHM it is simply the most natural choice for you (as far as Java is concerned). There may be some collection implementations that provide better performance, but frankly, I doubt it would be more than a marginal difference. One thing that might be significant in your case is that LHM is not synchronized. However, you may always use Collections#synchronizedMap() to enforce it. I looked in java.util.concurrent package, but haven't found ordered concurrent map implementation.
 
Rajkamal Pillai
Ranch Hand
Posts: 445
1
Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

A LikedHashTable would be synchronized too right?

Cheers,
Raj.
 
Dariusz Kordonski
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm afraid there is no such class in the Java API (at least I never heard of it ). There is java.util.Hashtable and java.util.concurrent.ConcurrentHashMap (which are quite similar, with the latter being a bit faster for some operations), but as far as I know, neither of them supports element ordering, which is one of Sreedhar's requirements.
 
Rob Spoor
Sheriff
Pie
Posts: 20611
63
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, you can always wrap your LinkedHashMap using java.util.Collections#synchronizedMap
 
Campbell Ritchie
Sheriff
Pie
Posts: 49827
69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Sagar Rohankar:
Look at this.
Did you actually look at it? All the information you require was there.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic