• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

Linked Hash Map

 
Ranch Hand
Posts: 154
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 2908
1
Spring Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Look at this.
 
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 479
1
IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Sheriff
Posts: 22799
131
Eclipse IDE Spring Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well, you can always wrap your LinkedHashMap using java.util.Collections#synchronizedMap
 
Marshal
Posts: 79699
381
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
The two armies met. But instead of battle, they decided to eat some pie and contemplate this tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic